1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

Unity Multiplayer character controller sample project

Discussion in 'Multiplayer Networking' started by seanr, Jun 11, 2015.

  1. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Attached is a simple character controller sample project.

    This does not do animation.

    (There is a NetworkTransform bug with syncing rotation for CharacterControllers. This projects contains a workaround script that can be used until that is fixed).
     

    Attached Files:

    erebel55 likes this.
  2. erebel55

    erebel55

    Joined:
    Jun 14, 2014
    Posts:
    42
    Thank you for this, great for my needs :) Will basic animation be added?
     
  3. raja-bala

    raja-bala

    Joined:
    Jul 11, 2012
    Posts:
    29
    Hey Sean,

    I was trying to get two players' animated characters working over the network. I wasn't sure how to correctly sync their animations. The input layer uses `isLocalPlayer`, and I was hoping the `sync character controller` option would be enough. When i used that, it wouldn't move at all (not just a rotation issue).

    If you'd like to check it out, here's the github link and the SO question.
     
    metamorphist likes this.
  4. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    In your ThirdPersonUserControl script, add:

    Code (CSharp):
    1.  
    2.         [Command]
    3.         void CmdMove(Vector3 move, bool crouch, bool jump)
    4.         {
    5.             RpcMove(move, crouch, jump);
    6.         }
    7.  
    8.         [ClientRpc]
    9.         void RpcMove(Vector3 move, bool crouch, bool jump)
    10.         {
    11.             if (isLocalPlayer)
    12.                 return;
    13.  
    14.             m_Move = move;
    15.             m_Crouch = crouch;
    16.             m_Jump = jump;
    17.             m_Character.Move(move, crouch, jump);
    18.         }
    Then call CmdMove for the local player, maybe in Update().
     
    raja-bala likes this.
  5. raja-bala

    raja-bala

    Joined:
    Jul 11, 2012
    Posts:
    29
    Thanks much @seanr!

    I removed the [SyncVar]'s in the script, in addition to that (since the RPC has the updated arguments at any point) and it works fine.

    Why didn't the earlier version work though? Since the movement variables were synchronized, it should have run the animation until each update, right?
    Also, when would I set `NetworkTransform.TransformSyncMode` to Sync Character Controller?
     
    metamorphist likes this.
  6. Meleong

    Meleong

    Joined:
    Sep 25, 2015
    Posts:
    1
    Thanks。
    非常感谢。
     
  7. FuTou

    FuTou

    Joined:
    May 2, 2015
    Posts:
    48
    I want to ask the same question as raja.bala:
    Why didn't the earlier version work though? Since the movement variables were synchronized, it should have run the animation until each update, right?
    Also, when would I set `NetworkTransform.TransformSyncMode` to Sync Character Controller?
     
  8. FuTou

    FuTou

    Joined:
    May 2, 2015
    Posts:
    48
    Thanks Sean, it's great. I still want to ask: when should we use NetworkedTransform (sync Character Controler)?
     
  9. jamius19

    jamius19

    Joined:
    Mar 30, 2015
    Posts:
    88
    How can I get it to work? :(