In NetworkTransform, a full snapshots get triggered even if only the position OR the rotation changed above the sensitivity value.
Describe the bug
If during an update cycle the rotation of an GameObject with a NetworkTransform (unreliable) component changes enough to be over the rotationSensitivity value, the rotationChanged flag gets set
https://github.com/MirrorNetworking/Mirror/blob/e92e91dcfdf0cf0995721a741c15c44e3af8821d/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs#L303
At the same time the position of the GameObject changes less than the positionSensitivity value and positionChanged does not get set
https://github.com/MirrorNetworking/Mirror/blob/e92e91dcfdf0cf0995721a741c15c44e3af8821d/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs#L302
In UpdateServerBroadcast then only the rotation value gets broadcasted
https://github.com/MirrorNetworking/Mirror/blob/e92e91dcfdf0cf0995721a741c15c44e3af8821d/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs#L129-L131
Afterwards the current snapshot (inlcuding the current position AND rotation values) are stored as the lastSnapshot and used for the next comparison, if the GameObject hast moved or was rotated.
[IMPORTANT] How can we reproduce the issue, step by step:
- create a scene for client-server with Mirror
- add a GameObject with the NetworkTransformUnreliable component
- add a script that rotates the GameObject serverside continously with 0.1 degree and moves it 0.01 units in one direction per update cycle
- set that rotation and position sensitivity to 0.05
- start the server and the client
- connect the client to the server
- the GameObject's rotation and position should change on the server, but on the client only the rotation changes, not the position
Expected behavior NetworkTransform updates position and rotation at least occationally, even when only one component is above its sensitivity value. In the given example, the rotation updates in every cycle, but the position updates in every 5th cycle when the accumulated position change exceeds the position sensitivity.
Desktop (please complete the following information):
- OS: Windows
- Build target: standalone
- Unity version: 2020.3
- Mirror branch: release 79.0.1
Additional context Small example with one dimentional position and rotation. changerate position: +0.8 changerate rotation: +1.5 position/rotaion sensitivities: 1.0
- Time t = 0:
- game object
- pos = 0
- rot = 0
- snapshot
- pos = 0
- rot = 0
- game object
- Time t = 1:
- game object
- pos = 0.8
- rot = 1.5
- checks
- pos: 0.8 - 0.0 = 0.8 < 1.0 > not send
- rot: 1.5 - 0.0 = 1.5 > 1.0 > send
- new snapshot
- pos = 0.8
- rot = 1.5
- game object
- Time t = 2:
- game object
- pos = 1.6
- rot = 3.0
- checks
- pos: 1.6 - 0.8 = 0.8 < 1.0 > not send
- rot: 3.0 - 1.5 = 1.5 > 1.0 > send
- new snapshot
- pos = 1.6
- rot = 3.0
- game object