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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Send RPC to a different Network ID

Discussion in 'Multiplayer' started by kalisclark, Dec 29, 2014.

  1. kalisclark

    kalisclark

    Joined:
    Sep 29, 2014
    Posts:
    33
    Hi guys,

    Does anyone know why I can't send an RPC to a different prefab? Basically I have 2 different prefabs and both get instantiated with the same script that sends out an RPC like so:

    networkView.RPC("CheckStatus", RPCMode.OthersBuffered);

    The problem is that it only works when the same prefab is used but when it's 2 different prefabs it doesn't work and I have tried to use "RPCMode.All" but still nothing.

    Is this because they need to be the same Network ID?

    Any help would be greatly appreciated.

    Many thanks
     
  2. kalisclark

    kalisclark

    Joined:
    Sep 29, 2014
    Posts:
    33
    Turns out I was missing something, doh! I needed to add the (Clone) part to the string in GameObject.Find.
    so in a different Script I have done:

    status = GameObject.Find("myPlayer(Clone)").GetComponent<StatusChecker>().status;

    status is the Boolean I change in the RPC

    Not sure if this will help anyone seeing as it was a silly mistake and I was looking at the wrong thing the whole time.