Network.Destroy(GO_Clone) only destroys locally - leaving 'ghosts' for other players?

Hey everyone,

I’ve run into a pretty weird problem. In my Networked game, whenever someone fires their laser a smoke plume is created using Network.Instantiate. Then when they release the Fire1 button, I remove it using Network.Destroy. However, during testing some players experienced huge lag spikes (which could be combated by them firing their laser). Also, say Player1 has fired his laser 5 times. When Player2 then joins the game, he sees 5 smoke plumes, as if they were never truly destroyed! o.o; This has got me a bit stumped… Does anyone know what’s going on? Here’s my code structure:

var laserSmoke : GameObject;
var laserSmokeClone : GameObject;
laserSmokeCreated = false;

function fireWeapon(){
//Called from Update();
//Switch-Case: If Fire1 is pressed and current weapon is laser --> fireLaser();

if (Input.GetButtonUp("Fire1")){
			switch(currentWeapon){
				case "Laser":
				Network.Destroy(laserSmokeClone); //works locally, object is removed from Hierarchy.
                                //smoke disappears for other users as well, but they get lag at some point.
				laserSmokeCreated = false;
				break;
			}
			firing = false;
}

function fireLaser(){
	if(!firing){
		laserSound.Play();
	}
	firing = true;

	var ray = playerCamera.ScreenPointToRay (Vector2(playerCamera.pixelWidth/2, playerCamera.pixelHeight/2));
	var hit : RaycastHit;
	if (Physics.Raycast (ray, hit, Mathf.Infinity)){	//Laser hit something
		if(!laserSmokeCreated){
			laserSmokeClone = Network.Instantiate(laserSmoke, hit.point, Quaternion.identity, 0);
			laserSmokeCreated = true;
		}
	laserSmokeClone.transform.position = hit.point;
	}
}

Thanks in advance! =)
-Patrick

Bump for great justice? =/ Still haven’t managed to track this bug down/ kill it.

“Bump me baby, one more time”

Network.Instantiate is buffered. Network.Destroy is not.

Therefore the Instantiate is still in the buffer when the new player joins and the objects get created for them.

A solution is to not use Network.Instantiate, you need to roll your own networked instantiation method using non-buffered RPCs if you want people to be able to join a game in progess. Search the network forums and you’ll find a few posts about this.

Here’s some relevant threads.

http://forum.unity3d.com/threads/10723-Bringing-newly-Client-Player-quot-up-to-Speed-quot?highlight=network.instantiate+network.destroy
http://forum.unity3d.com/threads/67158-Network-spawning-question?highlight=network.instantiate+network.destroy
http://forum.unity3d.com/threads/67648-Prevent-network-instantiation-on-certain-clients?highlight=network.instantiate+network.destroy
http://forum.unity3d.com/threads/70109-Trouble-with-new-players-connecting-and-bullets-spawning-like-mad?highlight=network.instantiate+network.destroy
http://forum.unity3d.com/threads/65012-Help!-how-to-Destroy-the-Network.Instantiate?highlight=network.instantiate+network.destroy

Ah, that explains it; thanks! I’m not sure how else to go about it yet, but thanks for pointing me in the right direction. =)

EDIT: Just saw your list of threads - thanks so much!! =D