x


Force a RPC to be called on a networkview of another GameObject

The error I get:

RPC call failed because the function 'IAmReady' does not exist in any script attached to'GameDirector'

So I have two game objects. One is called GameDirector which manages the logic for the current scene that is loaded (I am basically doing a bunch of multiplayer minigames). The other is called Director and this game object manages the communications to the master server and keeps track of the players and a bunch of other stuff that gives as little networking overhead as possible to the minigames so one can churn them out fast.

The problem I am having is that when the two players connect to eachother and start the game I need to make sure that both players have loaded the scene before I start instantiating the player characters (otherwise the Network.Instantiate will just get lost if a client is still loading). So I send out an RPC to all players when they have loaded. So when the player has received "IAmReady" from all other players then its time to start the game.

  1. The function for the RPC is inside a script of Director
  2. These queries are started when the GameDirector calls kDirector.DoneLoading() at the end of the Start() function of the logic script in GameDirector;
  3. For some reason the RPC tries to execute for scripts attached to GameDirector rather than for Director.
  4. The networkView.RPC call and the [RPC] function are in the same script file.
  5. How do you tell the networkView that the RPC should be executed on the Director instead? kDirector.networkView.RPC yields the same result.
more ▼

asked Jul 01 '10 at 09:40 AM

Henrik Poulsen gravatar image

Henrik Poulsen
164 2 2 8

Post some code here as its not clear if the eror is on the code or in your setup

Jan 01 '11 at 05:50 PM YeOldeSnake 1
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I hope this can help you, but to tell you the truth I was not able to make it work (seems to not even execute on my tests...)

GetComponents(NetworkView)[i].RPC()

as written on the official documentation that could be useful in your case. http://unity3d.com/support/documentation/Components/class-NetworkView.html

more ▼

answered Aug 02 '11 at 05:05 PM

roamcel gravatar image

roamcel
1.2k 37 40 44

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

I managed to solve a similar(ish) problem with this:

.GetComponent(NetworkView).networkView.RPC("MyFunction", RPCMode.AllBuffered, vars);

I hope this helps you and others that have a similar issue

more ▼

answered Mar 02 '12 at 12:21 AM

portchris gravatar image

portchris
46 1 2 3

(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:

x2097
x237
x116
x49
x45

asked: Jul 01 '10 at 09:40 AM

Seen: 3008 times

Last Updated: Mar 02 '12 at 12:21 AM