- Home /
Player not deleting on server exit
So, here's a slightly altered code from the IOS multiplayer
var Player : Transform;
var camera1 : Camera;
function OnNetworkLoadedLevel ()
{
camera1.enabled = false;
// Instantiating Player when Network is loaded
Network.Instantiate (Player, Vector3 (Random.Range (5, 95), 1000, Random.Range (5, 95)), transform.rotation, 0);
}
function OnPlayerDisconnected (player : NetworkPlayer)
{
Network.RemoveRPCs(player, 0);
Network.DestroyPlayerObjects(player);
camera1.enabled = true;;
}
Now my problem is the second part. So the player is supposed to be destroyed on exit, but isn't. I don't know anything about multiplayer and need some help.
Answer by testure · Jun 11, 2011 at 06:26 AM
You're going to need to post more code if you want help with this one- the code you posted for destroying a player object should work. Are you sure the player object is not destroyed? How did you go about verifying it? If you're relying on the camera being enabled to prove that the object was destroyed- it could be misleading, since if the player object was never properly instantiated, it will never have been destroyed.
The camera isn't the FPS camera, it's one that can fly over the landscape. Basically, when I disconnect, it stays on the player. If i reconnect, it makes a new player, but the old one is still there, and is still controlled by me. This is the entire code.
Your answer
Follow this Question
Related Questions
Network RPC buffer issue 0 Answers
How can I delete or destroy an instance of an object IN A MULTIPLAYER GAME?. 2 Answers
Destroy instances created continuosly of a prefab in a network game... 0 Answers
Network.Destroy doesn't remove objects on other systems? 2 Answers
How to properly destroy non-instantiated objects over a network? 1 Answer