RemoveRPCs and DestroyPlayerObjects

Hello, I’m developing an online game on Unity 5.0, and I’m having issues to properly destroy game objects.

Currently the server is the owner of all game objects (we might make missiles local some day).

When a game round is over, the server executes this:

public void finishGameClient ()
	Network.RemoveRPCs (networkPlayer);
	Network.DestroyPlayerObjects (networkPlayer);
	rpcScript.sendFinishClientGame (networkPlayer);

As a result, all game objects are destroyed on both the server and client, and the lobby menu is showed.

However, a message appears: “no objects for the given player ID were deleted 1”.
And if the client leaves the server and rejoins, the game objects reappear at the center of the screen and blink.

I don’t understand. Doesn’t that function remove all buffered calls to remote instantiation?

I’ve fixed the bug. The function

Network.RemoveRPCs (player);

removes the RPCs of the objects owned by the player. I wanted to destroy the server’s objects, so I rewrote the function finishGameClient() on the server side:

Network.RemoveRPCs (Network.player);

Then, the function

Network.DestroyPlayerObjects (player);

destroys all network objects of the player, but I want to keep the object containers. So I removed that line.

And the final touch was modifying the destroyer function:

Network.RemoveRPCs (gameObject.GetComponent <NetworkView>().viewid);
Network.Destroy (gameObject);