NetworkTransform
The position, rotation, and scale of a NetworkObject
is normally only synchronized once when that object is spawned. To synchronize position, rotation, and scale at realtime during the game, a NetworkTransform
component is needed. NetworkTransform
synchronizes the transform from server object to the clients.
NetworkTransform
covers most use cases for synchronizing transforms. For some special cases such as really fast paced games a custom implementation with a different interpolation algorithm might be better.
tip
You can have multiple NetworkTransform
components on child objects of your network object to synchronize individual positions of child objects.
#
Restricting SynchronizationQuite often not all transform values of a GameObject need to be synchronized over the network. For instance if the scale of the GameObject never changes it can be deactivated in the syncing scale
row in the inspector. Currently deactivating synchronization only saves on CPU costs but in the future it will also reduce the bandwidth used by NetworkTransform`.
#
ThresholdsThe threshold values can be used to set a minimum threshold value. Changes to position, rotation or scale below the threshold will not be synchronized That way minor changes to a value will not trigger a position synchronization which can help to reduce bandwidth.
note
Many small changes below the threshold will still result in a synchronization of the values as soon as all the accumulative changes cross the threshold.
#
Local SpaceBy default NetworkTransform
synchronizes the transform of an object in world space. The In Local Space
configuration option allows to switch to synchronizing the transform in local space instead.
Using local space
can improve the synchronization of the transform when the object gets re-parented because the re-parenting will not change the local space
transform of the object but would modify the global space
position.
#
InterpolationCheck the Interpolate
setting to enabled interpolation. Interpolation is enabled by default and is highly recommended. With interpolation enabled the NetworkTransform
smoothly interpolates incoming changes to position, rotation and scale. In addition interpolation buffers the incoming data with a slight delay and applies additional smoothing to the values. All these factors combined result in a much smoother transform synchronization.
When Interpolate
is disabled changes to the transform are applied immediately resulting in a less smooth position and more jitter.

#
ClientNetworkTransformNetworkTransform
always synchronizes positions from the server to the clients and position changes on the clients are not allowed. Netcode for GameObjects comes with a sample containing a ClientNetworkTransform
. This transform synchronizes the position of the owner client to the server and all other client allowing for client authoritative gameplay.
The ClientNetworkTransform
lives inside the Multiplayer Samples Utilities package. You can add this package via the Package Manager
window in the Unity Editor by selecting add from Git URL
and adding the following URL: "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main"
Or you can directly add this line to your manifest.json
file:
"com.unity.multiplayer.samples.coop": "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main"