Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Unity Multiplayer Synchronizing an entire skeleton

Discussion in 'Multiplayer Networking' started by seanr, Sep 17, 2015.

  1. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    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.
     

    Attached Files:

    Last edited: Sep 17, 2015
    BFips, Joobei, hippocoder and 2 others like this.
  2. Julien_

    Julien_

    Joined:
    Nov 12, 2013
    Posts:
    33
    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?
     
  3. iColpitts

    iColpitts

    Joined:
    Sep 30, 2015
    Posts:
    2
    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?
     
  4. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    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".
     
  5. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Make sure you have the latest Unity Editor patch release.
     
  6. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    to use a specific channel for a script add the NetworkSettings custom attribute:

    [NetworkSettings(channel=2)]
    class NetworkSkeleton: NetworkBehaviour
     
  7. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    This worked.
     
  8. Arcan-Studios

    Arcan-Studios

    Joined:
    Mar 12, 2015
    Posts:
    32
    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
     

    Attached Files:

  9. Joobei

    Joobei

    Joined:
    Oct 12, 2016
    Posts:
    3
    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.
     
  10. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    27
    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.
     
  11. jelliman1993

    jelliman1993

    Joined:
    Jul 18, 2017
    Posts:
    1
    Hi, did you have any luck fixing this?