Synchronizing an entire skeleton

Here is an example script that synchronizes the bones of an entire skeleton. This is intended to be used by dynamic animation systems driven by user input, such as Kinect systems doing motion capture for shared VR/AR environments. This could be used for regular Mecanim driven animation, but the bandwidth usage is much high than the usual methods.

(This is much more efficient than using 30+ NetworkTransformChild scripts to animate all the bones)

Instructions:

  • Add the NetworkSkeleton component to the root prefab with the Network Identity.
  • drag the root of the skeleton of the object into the Target slot.
  • disable the Animator and animation scripts on the object
  • make a script to enable the Animator and animation scripts in OnStartLocalPlayer

The size of the animation data may be quite big for large skeletons. Setting the SyncLevel can reduce the size - but deep child bones wont animate. For example, the avatar in the mecanim sample project is 78 bones.

If the size of the animation data is larger than the MTU (about 1400 bytes), add a UnreliableFragmented channel to your network configuration and specify that as the NetworkChannel.

The attached custom editor class must go into the Editor directory of the Unity project.

2299672–154825–NetworkSkeleton.cs (9.86 KB)
2299672–154826–NetworkSkeletonEditor.cs (4.93 KB)
2299672--154827--NetworkSkeleton.png

5 Likes

Wow, you guys are awesome, thanks for uploading this. This is extremely helpful for me.

Now say I want most of the bones (down to some sync level) to be controlled by the host (for all clients) and some bones on a deeper hierarchy level (e.g. the hands) by the clients themselves. What would be your suggested way of going about this? It seems I can only have one NetworkIdentity on the root of the skeleton, otherwise I could just attach another one to a child (the hand) and set their ‘localPlayerAuthority’ property accordingly. Any thoughts?

I’m attempting to use these scripts which are exactly what I’m looking for but, I’m getting the following errors:

Have I placed the scripts in the wrong folder? or have these functions bee deprecated?

Hi Sean,
Can you provide a sample for “If the size of the animation data is larger than the MTU (about 1400 bytes), add a UnreliableFragmented channel to your network configuration and specify that as the NetworkChannel.”

I tried following but could not get this working:

  • I have added one extra channel in NetworkManager’s advanced configuration. But this chanlle #2 is not visible in NetworkBehavior if I send a Command on Channel 2.

  • I also tried changing the Channel#1 to Unreliable Fragmented but it gives an error message
    “no free events for long message”.

Make sure you have the latest Unity Editor patch release.

to use a specific channel for a script add the NetworkSettings custom attribute:

[NetworkSettings(channel=2)]
class NetworkSkeleton: NetworkBehaviour

This worked.

i am using a character with animations and with bone rotations throw code in late update for ovewriting the animator, i am using network skeleton for sending bone transformation and work fine but the host, the host local player dont update in clients only the bone rotation throw code the animation works well

It would be nice if we could get an example project. I have a kinect but I don’t have a rig onto which I could drag these scripts.

I know this is an old-ish post but I just came across this same need. A few things are not clear, if I start this on a client then the animation is not in sync (start as in enabling the animation controller) - if I start it on the server then it is in sync however the animation on all clients (ie., except the server+client) the animation is not interpolated. I feel like I am missing something.

Anyone else having this issue or can shed some light?

Thanks.

Hi, did you have any luck fixing this?

Thanks very much!!!
Can you provide a sample project?

@l1141200632 … I have this working in my project. Let me know if you need any help

I know that this post is now 4 years old but thank you so much guys for sharing the script. It works great

It would be great to have these scripts for Mirror