at first i didnt notice it at all but it seems that if a client connects to the game late for some reason all object that were previously destroyed in that game are there. this is a problem since on the server side (the one that controlles the enemies) these objects are deleted and nothing is controlling them. also all player objects previously destroyed (that are also destroyed on all who are connected) are in the game with nothing controlling them. is there a way to make sure the deleted object wont show up on clients who connect after the objects are destroyed?
If you use Network.Instantiate, You must call Network.RemoveRPCs. Network.Instantiate, when called, leave a mark in the buffer (a list of “to do” actions when a client connect). Among them : the Network.Instantiate.
How to use Network.RemoveRPCs ? Well, who called the Network.Instantiate (and then, is the responsible of putting the RPC in the buffer) ?
The client ? It is the easier way : simply, upon client disconnection, call
function OnPlayerDisconnected (player : NetworkPlayer)
{
Network.RemoveRPCs (player);
}
If the server is the one who Network.Instantiate -ed the objects for the client, you must have specified a different group for each player, in order to differente those RPCs.
static function Instantiate (prefab : Object, position : Vector3, rotation : Quaternion, group : int) : Object
Groups are a … way to group RPCs … and Network.Instantiate. So, if you group all RPCs for each player, you can easily get rid of them later, by calling the right Network.RemoveRPCs.
Network.RemoveRPCs (Network.player, group); // Network.player is us, the server. Don't forget we are the one who N.Instantiate -ed the object, so the RPC is the buffer is ours !