x


RPC Calls Not Working

In simple, Unity just doesn't want to call my RPC functions.

My project is set up where a different scene and different script does the networking. For clients, the script is called "ConnectionScript", for server the script is called "ServerScript". They are both on the same viewID and both have a networkView attached to them with reliable compressed.

The code when I call (From ConnectionScript) is this:

networkView.RPC("test", RPCMode.Server);

The RPC code is (ServerScript):

[RPC]
public void test()
{
    Debug.Log("Test"); 
}

All connections work fine and I can easily connect to the server, but once I try and send an RPC, nothing appears to happen. I have the project settings set to run in the background, too.

Could somebody point me in the right direction?

Thanks!

more ▼

asked May 06 '12 at 04:35 PM

alexc1995 gravatar image

alexc1995
37 2 3 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Both sides need the RPC function "test". They can be different functions, but both sides need to have the function since it is possible to call it on your own client.

Usually you should get an error message that the RPC function wasn't found. Have you checked the error log?

more ▼

answered May 06 '12 at 04:55 PM

Bunny83 gravatar image

Bunny83
45.2k 11 49 207

Really? Who came up with that idea? It seems pretty strange to do that. I was initially using the method to authenticate a user, ie.

networkView.RPC("Auth", RPCMode.Server, "auth-code-here");

Does this mean I'll have to have a function which just sits there doing nothing in my client sided script:

public void Auth() {

}

Or does it take the same parameters?

Thanks.

May 06 '12 at 05:03 PM alexc1995
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x701
x237

asked: May 06 '12 at 04:35 PM

Seen: 876 times

Last Updated: May 06 '12 at 05:03 PM