Photon Fusion 2.1.1

NetworkTransformHelpers.NormalizedStallHeuristic Struct Reference

Public Member Functions

 NormalizedStallHeuristic (float minimumLinearError=0.01f, float directionSimilarityThreshold=0.95f, float correctionFractionThreshold=0.05f, float errorRatioThreshold=0.95f)
float StalledErrorCorrectionDetection (NetworkTransform networkTransform, float physicsDt, AbstractPhysicsBody physicsBody, Vector3 previousLocalPosition, Vector3 previousExtrapolatedPosition, ref KinematicSnapshot localSnapshot, ref KinematicSnapshot extrapolatedSnapshot)
 Implements the NetworkTransform.CustomErrorDetectionDelegate so it can be provided as a error detection heuristic for use on forecasted NetworkTransforms.

Detailed Description

Error detection heuristic that detects persistent stuck states. differs from the standard implementation in that it is normalized and time-step independent and tuned via 3 fractional or precentage based thresholds

Evaluates three conditions:

  1. Error direction similarity - are current and previous errors pointing the same way?
  2. Correction progress - are we making progress closing the gap?
  3. Error persistence - is the error magnitude staying the same or growing?

When all three indicate a problem (consistent error direction, no progress, error not shrinking), returns a positive score indicating error. Otherwise returns a negative score indicating healthy correction.

Constructor & Destructor Documentation

◆ NormalizedStallHeuristic()

NormalizedStallHeuristic ( float minimumLinearError = 0::01f,
float directionSimilarityThreshold = 0::95f,
float correctionFractionThreshold = 0::05f,
float errorRatioThreshold = 0::95f )

Constructs a NormalizedStallHeuristic

Once an instance has been made the NormalizedStallHeuristic.Delegate property can be assigned to the NetworkTransform.CustomErrorDetection delegate on a network transform to override the default stall heurstics algorithm used

Parameters
minimumLinearErrorError distances below this value will return -1f, the error is too small to care
directionSimilarityThresholdWhat proportion of the error from the previous frame needs to match this frame to be considered stalled?
correctionFractionThresholdWhat proportion of last frames error needs to have been corrected this frame to be considered not stalled?
errorRatioThresholdHow much does this frames error need to have shrunk by, compared with last frames error to not be considered stalled?

Member Function Documentation

◆ StalledErrorCorrectionDetection()

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

Implements the NetworkTransform.CustomErrorDetectionDelegate so it can be provided as a error detection heuristic for use on forecasted NetworkTransforms.

Parameters
networkTransformThe NetworkTransform being acted on
physicsDtThe physics timstep - seconds
physicsBodyThe PhysicsBody being actted on
previousLocalPositionThe local position of the object captured last FixedUpdate
previousExtrapolatedPositionThe extrapolated position of the object captured Last FixedUpdate
localSnapshotThe local physics snapshot for this FixedUpdate
extrapolatedSnapshotThe extrapolated physics snapshot for this FixedUpdate
Returns