Search Unity

Question Client RPC not found

Discussion in 'Netcode for GameObjects' started by Voliware, Feb 13, 2024.

  1. Voliware

    Voliware

    Joined:
    Feb 4, 2023
    Posts:
    15
    I have been stuck for a while on an issue where an RPC doesn't seem to be part of the RPC list. In this simplified component code, which is attached to a scene object (the main Game object), all I do is add a NetworkBehaviour to a List of items. This all works fine until I added the RPC.

    I am trying to bridge the NGO gap where, sure you can spawn and parent game objects, but it's very challenging to sync gameobject references. So the plan was to use a NetworkBehaviourReference, but I can't even get this RPC to fire without error. Initially I had a NetworkBehaviourReference but removed it just to see if that was the issue (maybe the object was invalid) but it just seems Unity cannot find this RPC. I've restarted, rebuilt, etc..

    Each time the error is a KeyNotFoundException with a different key.

    Code (CSharp):
    1.  
    2. public class Deck<T> : NetworkBehaviour where T : NetworkBehaviour
    3.   List<T> items = new();
    4.   public virtual void Add(T item)
    5.   {
    6.      this.items.Add(item);
    7.      if (this.IsServer)
    8.      {
    9.        this.AddItemClientRpc();
    10.      }
    11.   }
    12.  
    13.   [ClientRpc]
    14.   private void AddItemClientRpc()
    15.   {
    16.     // blows up
    17.   }
    18. }
    upload_2024-2-13_14-50-50.png
     
  2. NoelStephens_Unity

    NoelStephens_Unity

    Unity Technologies

    Joined:
    Feb 12, 2022
    Posts:
    259
    Sorry to hear you are having issues. If you could provide the version of NGO are you using then it will better help me determine what the issue might be.
     
  3. Voliware

    Voliware

    Joined:
    Feb 4, 2023
    Posts:
    15
    I've been able to resolve this by just restarting everything. It seems to happen occasionally and I understand Multiplayer Play Mode is experimental.
     
    NoelStephens_Unity likes this.