Search Unity

RPC calls wrong inherited script

Discussion in 'Multiplayer' started by Deleted User, Mar 8, 2017.

  1. Deleted User

    Deleted User

    Guest

    Hello folks :)

    On my gameobject I have a few scripts that represents a behaviour. Say Behaviour_A and Behaviour_B.
    Both of them inherits from the same abstract parent (call it Behaviour).

    In my abstract parent I define an RPC as follow:
    Code (CSharp):
    1.     [ClientRpc]
    2.     protected void RpcStart(string behaviourName)
    3.     {
    4.         Debug.Log("RpcStart " + behaviourName+ "    in Behaviour: " + ToString());
    5.     }
    Now, the problem is when that RPC is invoked for Behaviour B, it's always Behaviour A that receives it.

    Example of the log output:
    Why is that happening? Is it due to the fact that a ClientRPC function creates a unique ID and it associates with the first script it finds? If so, any suggestions on how I could handle this differently.

    The goal I have in mind, is when the Server starts a Behaviour, it then do an RPC to the said behaviour on the clients that can do something custom (mainly minor things. Going SyncVar is not an option).

    Thank you :D
     
  2. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97