- Home /
Possible Bug with RPC calls (Unity 2.6)
Hi,
I am currently developing a multiplayer action game with Unity 2.6. After working fine for a long time, I am suddenly getting Error Messages and the game stops functioning.
The Error Message is:
RPC call failed because the function 'RPCNetworkManagerReady' does not exist in any script attached to'Network Level Rip-In'
The strange part is, that the script which calls the function is in fact not attached to the 'Network Level Rip-In' Object, but to a GameObject called 'Game'. The basic application structure is this 'Game' object, which exists over the whole game and is conserved, if a new level is loaded.
Other objects, like menus or levels (like the 'Network Level Rip-In') are loaded when needed.
The script which is executed and produces the Error is the NetworkManager.cs, which is attached to the 'Game' object. The function is WaitForServer()
and is used to synchronize all clients and the server before the start of the game (written in C#):
public bool WaitForServer() {
if(offlineMode || Network.isServer)
return false;
if(waitingClients == 0) {
Debug.Log("NetworkManager.WaitForServer: Signaling READY to server");
networkView.RPC("RPCNetworkManagerReady", RPCMode.Server);
waitingClients = -1;
}
else if(waitingClients == 1) {
return false;
}
return true;
}
This script is called by another script, the GameLoader, which is attached to the 'Network Level Rip-In' object. As I already said, it is used to synchronize the game states of all Clients:
private IEnumerator LoadGame() {
/* ... more code ... */
if(!networkManager.IsServer()) {
do {
yield return 0;
} while(networkManager.WaitForServer());
} else {
do {
yield return 0;
} while(networkManager.WaitForClients());
}
/* ... more code ... */
}
LoadGame() is called by the Start() function of the GameLoader.cs:
void Start() { /* ... initializing variables ... */
StartCoroutine(LoadGame());
}
So if a multiplayer game starts, both the client and the server will begin loading their levels. If a client or a server is done, it will start waiting for the rest of the players. The server will give his go to all clients, if he received the ready signal from each client.
This would be our RPC call (networkView.RPC("RPCNetworkManagerReady", RPCMode.Server)), but it never reaches its destination. It seems, that the call is assigned to the wrong GameObject, but we already checked the IDs of the NetworkViews, which are the same on both client and server
If there is no flaw in the scripts I can only assume that this is a Unity-Bug mixing up the RPC call IDs. As I said, we attached a NetworkView component to each GameObject.
I would be pleased if there was a solution that did not include "upgrading to a newer version", since refactoring would surely kill our timeframe.
Answer by Christian Rie · Apr 27, 2011 at 12:33 PM
Seems like I found the solution. I had to stop all RPC calls and erase the RPC stack. Additionally I had to set the Network's levelPrefix to prevent the mixup of the game objects. The example that lead the way can be found here: http://unity3d.com/support/documentation/Components/net-NetworkLevelLoad.html
Your answer
Follow this Question
Related Questions
Animation refuses to play 1 Answer
How would you override Editor object dragging? 0 Answers
Calling functon attached to another object (Javascript) 2 Answers
Using Scripts in AssetBundles 0 Answers
Moveing my camera 1 Answer