RPC to server from client

Im trying to send the player’s username and password from the client to the server (then to the database which i have done successfully). On the client game controller I have this when the player attempts to log in:

GetComponent<NetworkView>().RPC("AuthLogin", RPCMode.Server, username, password);
//network.RPC() <- seems to obsolete, but oh well.

and then on my server controller I have this:

[RPC]
void AuthLogin(string user, string pass) {
    Debug.Log(user + ":" + pass);
}

It seems that its trying to look for the RPC function in the client’s controller… How do I make it send it to the server?

Here is the error:

RPC call failed because the function ‘AuthLogin’ does not exist in the any script attached to’C_controller’

RPC does a Remote Procedure Call on the GameObject your script is currently on.

For this you should have a single NetworkController GameObject which either the Client or Server controller scripts are on or a complete NetworkController script that handles both client and server code. You could also have both GameObjects and scripts exist on client and server and get the NetworkView of the server GameObject and RPC call on that.

If you don’t want to do any of that you’ll have to create your own RPC library.