- Home /
network.RPC behavior
Hello,
I am trying to call a function on the server from a client but I am having an error message :
RPC call failed because the function 'Accountcreation' does not exist in the any script attached to'Scriptholder'
I am not quite sure I master the behavior of RPC. Here is how I understand it:
On server: One game object with a Network View. On it, I have a Script and a function with @RPC above, called for example Accountcreation.
On my client: I have another Game Object also with a Network View. I have a script on it calling Accountcreation with the RPCMode.Server.
Am I missing something ?
Answer by Bunny83 · Dec 07, 2011 at 11:28 AM
The RPC is only send to the GameObject with the same NetworkViewID, not to all objects. Also both sides have to have the called function, the server and the client. They don't have to be the same fucntion, but they must exist even when only called on one side since it's potential possible to send it to everyone.
You can have two seperate sctipts for server and client and both contains the RPC functions but with different implementation (can be empty). The usual way is to have the same script on both sides and check with:
if (Network.isServer)
{
}
else if (Network.isClient)
{
}
Your answer
Follow this Question
Related Questions
RPC Call Mix Up Issues 0 Answers
Spawning Clients 1 Answer
Get RPC senders ID, or IP? 1 Answer
Server and network views 0 Answers
Why is this public variable the same on client and server? 1 Answer