Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.1k stars 430 forks source link

NetworkTransform can't be disabled via MonoBehaviour's enabled property, results in NT TICK DUPLICATE #2886

Closed zachstronaut closed 1 month ago

zachstronaut commented 2 months ago

If you disable NetworkTransform on all clients by setting the enabled property to false you get a bunch of these errors:

[Netcode] [NT TICK DUPLICATE] Server already sent an update on tick 2340 and is attempting to send again on the same network tick!

You can disable sync functionality without the errors by doing something like:

netTransform.Interpolate = false;
netTransform.SyncPositionX = false;
netTransform.SyncPositionY = false;
netTransform.SyncPositionZ = false;
netTransform.SyncRotAngleX = false;
netTransform.SyncRotAngleY = false;
netTransform.SyncRotAngleZ = false;

I would expect to be able to stop the NetworkTransform completely by setting enabled to false, or if that seems weird, then by some other mechanism.

NoelStephensUnity commented 2 months ago

Good catch and this just requires checking if it is enabled or not when updating and exiting early if not (or possibly de-registering)

miniwolf commented 2 months ago

@zachstronaut just confirming which version you are on. The error message is in 1.7.1 but changed during 1.8.0: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/2777 It might be enough for you to upgrade to resolve your error.

miniwolf commented 1 month ago

Closing this as I have received no more information. If this is still an issue on the latest version 1.9.1 feel free to re-open or make a new ticket.