Unity is returning 3 " BCE0020: An instance of type ‘UnityEngine.NetworkView’ is required to access non static member ‘RPC’." in the position indicated in the script.
The script is attached to a NetworkView component and state sync is turned off…
private var firing : boolean = false;
//Enable or disable user controls
function SetEnableUserInput(enableInput)
{
queryUserInput=enableInput;
}
function FixedUpdate()
{
if(queryUserInput)
{
if (Input.GetButton ("Fire1") !firing) NetworkView.RPC("Firing",RPCMode.All); // minimizing sendmessage traffic
else
if (firing) NetworkView.RPC("StopFiring",RPCMode.All);
if (Input.GetButtonDown("Eject")) NetworkView.RPC("Ejecting",RPCMode.All);
}
}
@RPC
function Firing()
{
BroadcastMessage("Fire",SendMessageOptions.DontRequireReceiver);
firing = true;
}
@RPC
function StopFiring()
{
BroadcastMessage("StopFire",SendMessageOptions.DontRequireReceiver); /// unity error here
firing = false; /// and here
} /// and here
@RPC
function Ejecting()
{
BroadcastMessage("Eject",SendMessageOptions.DontRequireReceiver);
}
There’s NetworkView, which is a class. And there’s networkView which is a member instance variable inherited from Component (both GameObject and MonoBehavior are subclasses of Component). RPC(…) is an instance method which means that it operates on an instance (which is the usual case in object oriented programming). In the Unity API, there’s also a lot of static methods, which operate on the class.
So the error message you received basically means “hey homes, there is a method called RPC in the class NetworkView, but it’s not declared static so you better send it to an instance of NetworkView instead of the class itself”