This document is about: QUANTUM 2
SWITCH TO

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:

  1. None: the entity is created at a specific position / rotation and it is not updated in following frames; use this for static entities.
  2. 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.
  3. 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.
  4. 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.

fps template transform synchronization editor view
Transform Synchronization of the `Entity` component in Editor View

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% of RTT Factor)
  • Position Interpolation Speed: relative speed of delta-time based interpolation, decreased by (Position Interpolation Speed multiplied by 75% of RTT 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% of RTT Factor)
  • Culled Position Prediction Source: source of velocity (PhysicsBody3D / Movement component) for prediction
  • Min 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 resetting
  • Rotation 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 than Max RTT Prediction Threshold, so RTT Factor = 100% of RTT Relaxing Factor property)
  • Position Teleport Distance = 2 + 2 * 2 * RTT Factor = 4
  • Position Interpolation Speed = 8 - 8 * 0.75 * RTT Factor = 5
  • Culled 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 at Error Position Blend Start/Error Rotation Blend Start distance and closer, multiplied by delta time
  • Error Correction Rate Max: how fast is the position / rotation error decreased at Error Position Blend End/Error Rotation Blend End distance and further, multiplied by delta time
  • Error Correction Extrapolation: optional transform extrapolation for unsimulated Quantum frames (0-100%, based on QuantumGame.InterpolationFactor)
  • Error Position Blend Start: position distance from uninterpolated position where error correction rate starts blending from Error Correction Rate Min to Error 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 from Error Correction Rate Min to Error 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 resetting
  • Error 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 from Error Correction Rate Min to Error 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 from Error Correction Rate Min to Error 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 resetting
  • Error Rotation Interpolate Speed: how fast the current rotation interpolates to uninterpolated rotation, multiplied by delta time (only for culled entities)
Back to top