Problems with Network.destroy

So in my game my character has a self-destruct feature. With this code:

if(networkView.isMine){
			if(Input.GetKeyDown (KeyCode.Mouse0)){
				GameObject instantiatedProjectile = (GameObject)Network.Instantiate(sefDestruct, transform.position, transform.rotation,0);
				instantiatedProjectile.GetComponent<Detonator>().Explode();
				Network.Destroy(this.gameObject);
			}
		} 

my character doesn’t dissapear on fire. But if I comment out the two lines spawning the explosion then he does.

//GameObject instantiatedProjectile = (GameObject)Network.Instantiate(sefDestruct, transform.position, transform.rotation,0);
//instantiatedProjectile.GetComponent<Detonator>().Explode();

What gives?

Are there any errors printed out? Sometimes when Unity runs into errors, some undesirable things can happen to the things near the error.

–

1 Answer

1

So I fixed it but I don’t understand the reasoning why my fix works. When I destroy myself on the next frame everything seems to work out fine.