com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

fix: NetworkTransform Bitset not being properly reset if there is no delta [MTT-4275]

Open NoelStephensUnity opened this issue 3 years ago • 0 comments

Bandwidth Consumption Fix: NetworkTransform's NetworkTransformState.Bitset was having bits set but never having bits "un-set" when there was no delta from the previous relative value or the delta had not crossed the threshold. This would result in any axis marked to synchronize previously being always marked to be synchronized which, in turn, would cause all marked axis to be sent anytime a delta in any of the marked axis crossed the threshold value.

On the non-authoritative side, NetworkTransform.ApplyInterpolatedNetworkStateToTransform was using the NetworkTransform.Sync<Position,RotAngle,Scale> (i.e. NetworkTransform.SyncPositionX) as the determining factor as to whether it should apply all associated axis values as opposed to checking the updated NetworkTransformState.Has<Position,RotAngle,Scale> to determine if it should be updated locally.

Example of the Bitset Issue:

  • The authoritative transform detects changes to transform.position.x that exceeds the threshold
    • The transform.position.x bit flag is added to the authoritative state which is then synchronized with all non-authoritative remote instances
  • Some time later, the authoritative transform detects changes to the transform.position.z and transform.localScale.y
    • The transform.position.z and transform.localScale.y bit flags are added to the authoritative state which is then synchronized with all non-authoritative remote instances
      • The state synchronizes the transform.position.x, transform.position.z, and transform.localScale.y values
  • Some time later the authoritative transform only detects a change in transform.position.y that exceeds the threshold.
    • The transform.position.y bit flag is added to the authoritative state which is then synchronized with all non-authoritative remote instances
      • The state synchronizes the entire transform.position and the transform.localScale.y values.

Authoritative Side Interpolation Fix This includes changes to fix the issue where the authoritative side was interpolating when it should not be.

Client/Owner Authority Adjustments This includes adjustments to how we handle client-owner authority. Instead of sending a ServerRpc which makes adjustments to a server write authority NetworkVariable, NetworkTransform now creates two versions of the NetworkVariable with one having server write permissions and the other having owner write permissions.

Pertains to #2022 and #2093, BR-694

Changelog

  • Fixed: WIP

Testing and Documentation

  • Includes integration tests. (WIP)

NoelStephensUnity avatar Aug 03 '22 20:08 NoelStephensUnity