Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Unity Multiplayer ClientRpc not working OnStartLocalPlayer

Discussion in 'Multiplayer Networking' started by wahyuway, Mar 19, 2017.

  1. wahyuway

    wahyuway

    Joined:
    Oct 7, 2013
    Posts:
    72
    Hi, i tried to instantiate my player object using ClientScene.AddPlayer and make necessary change in OnServerAddPlayer.

    The problem is when i need to send my player parameter to other client using [Command] and [ClientRpc], ClientRpc did not executed.
    This some snippet of my player networkbehavior
    Code (CSharp):
    1.     public override void OnStartLocalPlayer() {
    2.         if (hasAuthority)
    3.             CmdCreateChar();
    4.     }
    5.  
    6.     [Command]
    7.     void CmdCreateChar()
    8.     {
    9.         print("client command me to execute this");
    10.         RpcCreateChar();
    11.     }
    12.  
    13.     [ClientRpc] //never called
    14.     void RpcCreateChar()
    15.     {
    16.         print("Server send this rpc to execute on all client");
    17.     }
    Any hint whats wrong?
     
    Last edited: Mar 19, 2017
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    199
    Hmm, have you tried using the OnStartClient override instead of OnStartLocalPlayer? The documentation isn't very clear here but based on the naming of the OnStart* methods of a NetworkBehaviour script, I would assume that OnStartLocalPlayer is used in more unique scenarios, where as OnStartClient will be called when the object is network-ready in the client.

    Not sure if this will help but hopefully it does!