Photon Fusion 2.1.1

NetworkTransformHelpers Class Reference

Class of useful helpers for the NetworkTransform. More...

Classes

struct  NormalizedStallHeuristic

Static Public Member Functions

static void ApplyCorrection (NetworkTransform nt, float physicsDt, float physicsFps, AbstractPhysicsBody physicsBody, float timeSinceLastOnCollisionEnter, ref KinematicSnapshot localSnapshot, ref KinematicSnapshot remoteSnapshot, ref KinematicSnapshot extrapolatedSnapshot)
 Compute error between local and extrapolated kinematic snapshots and apply a correction.
static void ComputeExtrapolatedSnapshot (NetworkTransform nt, float physicsDt, AbstractPhysicsBody physicsBody, float ticksToExtrapolate, ref KinematicSnapshot local, ref KinematicSnapshot remote, out KinematicSnapshot result)
 Extrapolate with an explicit ticksToExtrapolate value. The passed ticksToExtrapolate is normally clamped to PhysicsSettings.MaxExtrapolationTime in ticks.
static float DefaultStalledErrorCorrectionDetection (NetworkTransform networkTransform, float physicsDt, AbstractPhysicsBody physicsBody, Vector3 previousLocalPosition, Vector3 previousExtrapolatedPosition, ref KinematicSnapshot localSnapshot, ref KinematicSnapshot extrapolatedSnapshot)
 This is the default stall detection heuristic that the forecast physics uses.

Detailed Description

Class of useful helpers for the NetworkTransform.

Member Function Documentation

◆ DefaultStalledErrorCorrectionDetection()

float DefaultStalledErrorCorrectionDetection ( NetworkTransform networkTransform,
float physicsDt,
AbstractPhysicsBody physicsBody,
Vector3 previousLocalPosition,
Vector3 previousExtrapolatedPosition,
ref KinematicSnapshot localSnapshot,
ref KinematicSnapshot extrapolatedSnapshot )
static

This is the default stall detection heuristic that the forecast physics uses.

It carries out two checks

  1. It calculates how much the error vectors have changed, from the last frame to this frame
  2. It calculates how much of the last frames error was corrected

It then compares these values against the thresholds supplied in the PhysicsSettings on the network transform. Namely PhysicsSettings.HighErrorSimilarityThreshold and PhysicsSettings.LowCorrectionProgressThreshold

This default heuristic can be replaced with custom implementation by setting NetworkTransform.CustomErrorDetection on a NetworkTransform

Note: An alternative heuristic has been provided that works similarly to this but uses normalized vectors NormalizedStallHeuristic

Parameters
networkTransformThe network transform being checked
physicsDtThe timestep of the physics system
physicsBodyThe physics body being forecasted
previousLocalPositionThe world space position captured last FixedUpdate
previousExtrapolatedPositionThe desired extrapolation position captured last FixedUpdate
localSnapshotThe local physics data for this object for this FixedUpdate
extrapolatedSnapshotThe desired extrapolated physics data for this object for this FixedUpdate
Returns