Hi All,
So here’s the setup:
I have a GameObject with a Network Identity and Local Player Authority.
I have a base class and two child classes that extend the base class. The base class makes an Rpc call.
I want to put both of these child classes on the same object, but when I do that, the Rpc call executes on the first class attached to the object, rather than the one that made the call.
Of course, I could have a child object with a separate NetworkIdentity store one of the Child classes, but I wanted to know whether this is a bug in Unity, or if it’s intended behavior, or if I’m just doing something wrong.
The “Base” class looks something like this:
using UnityEngine;
using UnityEngine.Networking;
public abstract class Base : NetworkBehaviour {
// The client's player object
public GameObject player;
public void Execute() {
if(player.GetComponent<NetworkIdentity>().isServer)
{
RpcExecute();
} else {
CmdExecute();
}
}
[Command]
public void CmdExecute() {
RpcExecute();
}
[ClientRpc]
public void RpcExecute() {
Actions();
}
public abstract void Actions();
}
And the two sub-classes, ChildA and ChildB, both look like this:
using UnityEngine;
using UnityEngine.Networking;
public class ChildX : Base {
public override void Actions {
// Execute some actions here
}
}
Any feedback is appreciated!