Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Am I handling RPCs right?

Discussion in 'Multiplayer' started by TJB, Aug 21, 2008.

  1. TJB

    TJB

    Joined:
    Mar 20, 2007
    Posts:
    146
    Ok, so in a system I'm working on, a player sends a rpc to the server with some info. The server then selects only the players that need the info and sends a rpc to each of them with the info. So it becomes apparent that certain rpcs will only be used on the client and some will only be used the server end. But if I only include the server rpcs only on the server when the client tries to send the rpc to the server instead of sending it it gives an error. It seems that the rpc has to exist on the client despite it having code only the server would ever use. The only way around this i've found is to make a empty rpc on the client side. Is it okay to leave these "ghost" rpcs or am i missing something or using rpcs stupidly... or

    If you need clarification on the above let me know... I think it's a little hard to read, but I don't know how to make it clearer.

    Thanks for any help you can provide.
     
  2. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    277
    Yes, the client must have the definition details of the RPC function before it can invoke it, even if it is never a receiver for the RPC. It's perfectly save to define the RPC function on the client side as an empty function, it just needs to be identical to the server definition.