Unity 5.5.0f3 - Updating Object Using ClientRpc Requests "No behavior found for calling Rpc ..."

I am working on the teammatch team. Each team has its own spawn and the goal is to destroy the other team. Spawn are installed on the network in the form of 3 objects - the actual spawn (referred to later as physical spawn ), visible only to the server , an object called MapManager is present in both the client and the server , which acts as a messenger via Rpc calls and a simple spawn schedule ( link to it later visual belt ) present on client and local player...

NetworkIdentity parameters for each object, respectively:

  • Server only,
  • Local agent,
  • No - it's MonoBehaviour.

The physical spawning judge evaluates whether the spawn has been damaged and, if so, sets the isHealthChanged flag to true .

public class SpawnerServer : NetworkBehaviour {
    //used to determine whether has the health changed
    bool isHealthChanged = false;
    //indicates the team of this spawner via enum state
    public Data.teams myTeamEnum;
    ...
    public RectTransform healthBar;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Checking whether the bullet wll damage the spawn
        OnChangeHealth(healthPoints);
    }
    //if the health changed, change the healthbar as well
    public void OnChangeHealth(float healthPoints)
    {
        if (isServer)
        {
            ...
            isHealthChanged = true;
        }
    }
     //returns the deltaSize of the healthbar
     public Vector2 GetHealthbarSizeDelta()
    {
        return healthBar.sizeDelta;
    }
    //switches the healthChanged bool back to false. Called by the MapManager
    public void UncheckHealthChanged()
    {
        isHealthChanged = false;
    }
    //returns the state of the healthChanged bool
    public bool IsHealthChanged()
    {
        return isHealthChanged;
    }
}

      

MapManager checks the state of the flag in both physical belts (only checked on the server) and when true

  • clears the false flag ,
  • gets the width of the control panel,
  • passes information about the new width of the dashboard and the amount of spawn to the RPC call RpcChangeSpawnersHealthClients () , which calls the function responsible for updating the data about transforming the dashboard visual spawning .

    public class ClientSpawnControl : NetworkBehaviour {
    //the references to scripts of the server spawns, required for checking whether has
    //the state of any of the spawns changed
    public SpawnerServer serverSpawn1;
    public SpawnerServer serverSpawn2;
    //the references to spawns that belong to the clients
    public SpawnerClient clientSpawn1;
    public SpawnerClient clientSpawn2;
    
    //acts as a messenger that forces change of spawn healthbars in clients
    [ClientRpc]
    private void RpcChangeSpawnersHealthClients(int whatTeam, float healthChangeDelta)
    {
        if(clientSpawn1 != null)
        {
            if (whatTeam == (int)clientSpawn1.myTeam)
            {
                clientSpawn1.OnChangeHealth(healthChangeDelta);
                return;
            }
        }
        if(clientSpawn2 != null)
        {
            if (whatTeam == (int)clientSpawn2.myTeam)
            {
                clientSpawn2.OnChangeHealth(healthChangeDelta);
                return;
            }
        }
    }
    // Update is called once per frame
    void Update () {
        if (!isServer)
            return;
        if(serverSpawn1.IsHealthChanged())
        {
            serverSpawn1.UncheckHealthChanged();
            RpcChangeSpawnersHealthClients((int)serverSpawn1.myTeamEnum, serverSpawn1.GetHealthbarSizeDelta().x);
        }
        if (serverSpawn2.IsHealthChanged())
        {
            serverSpawn2.UncheckHealthChanged();
            RpcChangeSpawnersHealthClients((int)serverSpawn2.myTeamEnum, serverSpawn2.GetHealthbarSizeDelta().x);
        }
    
    }
    
          

An exception is thrown here: "No behavior found for incoming [ClientRpc: InvokeRpcRpcChangeSpawnersHealthClients] in TeamSelector (UnityEngine.GameObject), server and client must have the same NetworkBehaviour ..."

The error is quite interesting as the mentioned TeamSelector has nothing to do with updating manufacturers. It is used at the beginning to initialize the team data of the players, nothing more. Moreover - one of the physical spawns is somehow spawned on the client, although if I remember correctly, the Server only setting should prevent this behavior, and I'm not trying to create an object over the network anyway.

I used to try to create irregular visual spawns armed with NetworkBehaviour and NetworkIdentity - there was an error that these objects could not be created in the client even though I registered the objects in the Network Manager and even used the ClientScene.RegisterPrefab () method . I did my best combination of the two - the situation has not changed. Later, I regrouped the visual spawns to their current shape and tried to call an RPC call from MapManager from the physical spawns as soon as they detected a change in health. Got a similar exception thrown to the client to the above, but with the name of one ofphysical spawns instead of the TeamSelector object . Finding solutions didn't bring up anything that could work, for example I don't have methods that have duplicate names but belong to different namespaces.

I don't even know where to look for the source of the problem. After more than three days of arguing with Unity, I feel like it just doesn't want me to create this game. Does anyone know what might be causing the problem?

I am terribly sorry for the length of this post, but I have no idea how to describe this problem in short.

+3


source to share





All Articles