- Home /
RPC not being called
I have set up a server and a client, both only a main camera, both only 1 script. The client connects (this is successful, disconnecting after is shut down works as well, no network issues). This then calls the SERVERS RPC. Client uses:
void OnConnectedToServer() {
Debug.Log("Connected to server");
MakeCall();
}
// Update is called once per frame
void MakeCall () {
networkView.RPC("DataRequest",RPCMode.Server,"test");
}
And then the server has:
[RPC]
void DataRequest(string JsonCall, NetworkMessageInfo info){
Debug.Log("Made a data request: " + info.sender);
}
However, this setup results in one and the same error over and over:
RPC call failed because the function 'DataRequest' does not exist in the any script attached to'Main Camera'
I am at a complete loss as to why this happens, since the script is running on the Main Camera object. Does anyone know what is going on?
Thanks in advance, Smiley
Answer by Vince_H · Dec 14, 2013 at 08:04 PM
Answered, after hours of searching and posting this, i finally found it. The SENDER needs the exact same RPC method, it can be an empty method, but it NEEDS to be there or it will not work. even if it is told to send it to SERVER only as mode. Unity should really document this somewhere.
Your answer
Follow this Question
Related Questions
RPC to server from client 1 Answer
ClientRpc not called on Client 1 Answer
Network how to send data/activate function 1 Answer