Search Unity

RpcClient does not work on Host

Discussion in 'Multiplayer' started by yruama69, Aug 23, 2016.

  1. yruama69

    yruama69

    Joined:
    Jan 19, 2016
    Posts:
    2
    Hello,

    I'm trying to make awesome games, but it does not work !

    Actually, i'm just trying to spawn an object. It works for all client but not the host.

    Here my simple code :

    Code (CSharp):
    1.  
    2. void Start()
    3. {
    4.    if (isLocalPlayer)
    5.       CmdInit();
    6. }
    7.  
    8.    [Command]
    9.     public void CmdInit()
    10.     {
    11.         Debug.Log("Command ok");
    12.         if (!isClient)
    13.         {
    14.             CreatePlayer();
    15.         }
    16.  
    17.         RpcInit();
    18.     }
    19.  
    20.     [ClientRpc]
    21.     public void RpcInit()
    22.     {
    23.         Debug.Log("Rpc ok");
    24.         CreatePlayer();
    25.     }
    I can see "Command Ok" but not "Rpc ok".

    When i display (isClient) it's return "true" ;)


    Can you explain me why only host bug ?

    Thanks
     
  2. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    You need to be more thorough in explaining the issue. If you are having the problem and you're only running one instance of your "game" then that explains it all. ClientRpc are only called on Clients, not the Server/Host. Command are only called on Server/Host not Clients. So obviously you would have to run two instances of your project (one server/host and one client) and have a way to Debug them each to see this in effect.,