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

ClientRPC tag makes my function not fire.

Discussion in 'Multiplayer' started by Mytts, Aug 6, 2016.

  1. Mytts

    Mytts

    Joined:
    Jun 10, 2015
    Posts:
    10
    I am currently developing a multiplayer game and we recently converted from the legacy multiplayer system to the new one. Far most things seems to be going smoothly but I seem to be having one problem.

    I have functions for most of my objects to initiate them properly, these functions gets broadcasted across the network and are thus classified as RPC functions. The problem I'm having is that for one particular object, when I have the [ClientRPC] tag, the function does not seem to run, but when I remove the tag it does indeed run.

    The code to spawn the object is as following:

    GameObject crd = Instantiate(prefabToSpawn, basicPos, quat) as GameObject;
    NetworkServer.Spawn (crd);
    Debug.Log ("Check1");
    (crd.GetComponent<enemycard>() as enemycard).RpcStartC(unit, player);
    Debug.Log ("Check2");​

    Both Check1 and Check2 fires, but the RpcStartC is never called and I get no error message.

    Obviously, I have checked that it does have a network identity assigned to it and verified that it is listed in my networkmanagers spawnable objects.

    Edit: Only the local client does not get the RPC call.
     
    Last edited: Aug 6, 2016
  2. Mytts

    Mytts

    Joined:
    Jun 10, 2015
    Posts:
    10
    Well, after a lot of fiddeling I have somewhat figured it out... It seems that when doing a scene change, RPC's will not be able to run for a certain amount of time after the scene change, so you need to add a forced delay.