Search Unity

ClientRpc call on unspawned object - Player?

Discussion in 'Multiplayer' started by SpeakUpGames, Sep 1, 2015.

  1. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    I have an object managing the networked game (things like match time, initializing players at the start, etc).
    When I try to use it to call a public client Rpc function on the player prefab, it gives me a "ClientRpc call on un-spawned object" error.

    I assume the player prefab is spawned because it's handled automatically by the network manager. Why would I be getting this error then?
     
  2. TehGM

    TehGM

    Joined:
    Nov 15, 2013
    Posts:
    89
    I assume it's a scene object. I'm not sure why does it happen (I decided to go with my own flow of spawning/messaging in many cases), but I can suggest you a solution: NetworkMessages. For NetworkMessages, the object doesn't need to be NetworkBehaviour, thus it won't be disabled on scene load until server spawns, etc.
     
  3. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    Thanks for the advice. I believe the issue actually may have had something to do with calling a client Rpc function on non-local players. When I checked isLocalPlayer before calling the Rpc, the message went away. Perhaps it's simply poorly worded.