Synchronization
The Entity
component allows to synchronize the position and rotation of the entity. The synchronization type can be tweaked via the fields called Position Synchronization
and Rotation Synchronization
. This split permits tweaking the synchronization mode for each individually to achieve the most suitable combination for the game. The FPS Template supports 4 transform synchronization modes for an entity in Unity:
None
: the entity is created at a specific position / rotation and it is not updated in following frames; use this for static entities.Simple
: the entity position / rotation is updated every frame to the exact position / rotation of corresponding Quantum entity; use this for entities which do not require smooth movement.Interpolate
: the entity position / rotation interpolates to simulation position / rotation; this is the best option for entities which often change direction unpredictably (e.g. player) or when the client experiences bad network conditions.Error Correction
: the entity position / rotation converge to simulation position / rotation based on prediction error; this is best used for entities which do not unpredictably change direction often (e.g. AI).
Transform synchronization parameters -including synchronization mode- can be changed at runtime and resets on spawn to default.
Interpolation
The available parameters for adjusting the interpolation behavior are:
Position Teleport Distance
: maximum allowed position distance of a Unity entity from it's related Quantum entity position before hard resetting; increased by (Position Teleport Distance
multiplied by 200% ofRTT Factor
)Position Interpolation Speed
: relative speed of delta-time based interpolation, decreased by (Position Interpolation Speed
multiplied by 75% ofRTT Factor
)Culled Position Prediction
: prediction for culled entities based on entity velocity, 0-100% velocity for all predicted frames, decreased by (Culled Position Prediction
multiplied by 100% ofRTT Factor
)Culled Position Prediction Source
: source of velocity (PhysicsBody3D
/Movement
component) for predictionMin RTT Prediction Threshold
: lower bound of RTT when interpolation parameters does not change (RTT Factor
= 0.0f)Max RTT Prediction Threshold
: upper bound of RTT when interpolation parameters are fully relaxed (RTT Factor
=RTT Relaxing Factor
)RTT Relaxing Factor
: how much should be the interpolation relaxed (0-100%)Rotation Teleport Distance
: maximum allowed rotation difference (degrees) of Unity entity from Quantum entity rotation before hard resettingRotation Interpolation Speed
: relative speed of delta-time based interpolation
Provided perfect network conditions (e.g. RTT 40ms), interpolation values are the same as in the image above. In case of bad network conditions (e.g. RTT 200ms), parameters are following:
RTT Factor
= 0.5 (RTT is higher thanMax RTT Prediction Threshold
, soRTT Factor
= 100% ofRTT Relaxing Factor
property)Position Teleport Distance
= 2 + 2 * 2 *RTT Factor
= 4Position Interpolation Speed
= 8 - 8 * 0.75 *RTT Factor
= 5Culled Position Prediction
= 0.85 - 0.85 *RTT Factor
= 0.425
In this worst case scenario, compared with the original values, the entity has a 200% teleport distance tolerance, 37.5% slower interpolation speed and does 50% less velocity prediction. This helps greatly with reducing movement artifacts when movement direction changes are unpredictable.
Error Correction
The available parameters for adjusting the error correction behavior are:
Error Correction Rate Min
: how fast is the position / rotation error decreased atError Position Blend Start
/Error Rotation Blend Start
distance and closer, multiplied by delta timeError Correction Rate Max
: how fast is the position / rotation error decreased atError Position Blend End
/Error Rotation Blend End
distance and further, multiplied by delta timeError Correction Extrapolation
: optional transform extrapolation for unsimulated Quantum frames (0-100%, based onQuantumGame.InterpolationFactor
)Error Position Blend Start
: position distance from uninterpolated position where error correction rate starts blending fromError Correction Rate Min
toError Correction Rate Max
(Error Correction Rate Min
is the current value)Error Position Blend End
: position distance from uninterpolated position where error correction rate stops blending fromError Correction Rate Min
toError Correction Rate Max
(Error Correction Rate Max
is the current value)Error Position Teleport Distance
: maximum allowed position distance of Unity entity from Quantum entity position before hard resettingError Position Min Correction
: minimum correction of position in single frame (distance)Error Position Interpolate Speed
: how fast the current position interpolates to uninterpolated position, multiplied by delta time (only for culled entities)Error Rotation Blend Start
: rotation difference (radians) from uninterpolated rotation where error correction rate starts blending fromError Correction Rate Min
toError Correction Rate Max
(Error Correction Rate Min
is the current value)Error Rotation Blend End
: rotation difference (radians) from uninterpolated rotation where error correction rate stops blending fromError Correction Rate Min
toError Correction Rate Max
(Error Correction Rate Max
is the current value)Error Rotation Teleport Distance
: maximum allowed rotation difference (radians) of Unity entity from Quantum entity rotation before hard resettingError Rotation Interpolate Speed
: how fast the current rotation interpolates to uninterpolated rotation, multiplied by delta time (only for culled entities)