I’m encountering a problem with rotating a bone in my armature in Unity and synchronizing this rotation across all clients using the NetworkTransform component. The bone rotation is handled in LateUpdate(), and it functions correctly on the local client. However, the rotation does not propagate to other clients over the network. Although I’ve added the NetworkTransform component to the bone, it doesn’t seem to be working.
This is my desired behaviour:
If anyone has a solution for this issue, your help would be greatly appreciated. Thank you!
I wouldn’t use a NetworkTransform for bone animations. A NetworkVariable will be more efficient since this is only rotation along one axis. I’ve done this with a simple NetworkVariable even by compressing the 0-360 angle to a 0-255 value range which provides with about 1.5 degree angle changes, perfectly suitable for this use case.
Here you don’t even have to compress the byte because the rotation range is less than 255 degrees to begin with.
This means you’re synchronizing a single byte rather than 16 bytes (quaternion).
If you insist on NetworkTransform make sure one of the parents (typically the root) in the prefab has a NetworkObject component and the NetworkTransform must be set to transfer rotation in local space only, and uncheck all position, rotation, and scale checkboxes that you do not need.
(Oh wait, Fish-Net, I was thinking NGO … but it may have similar properties).
I’ve noticed that if I disable the Animator and NetworkAnimator, the synchronization of the bone rotation works on the other clients (therefore NetworkTransform is not the issue, maybe).
This leads me to believe that the issue is not with the local animation (I’ve also ensured there are no keyframes affecting the bone I’m rotating) but rather with the NetworkAnimator component.
Unfortunately, I haven’t been able to find much information on this, and it’s driving me crazy.
For anyone encountering a similar issue in the future, here’s the fix: avoid using LateUpdate for this task. Instead, opt for Unity’s RigBuilder and then place the NetworkTransform in the target object.