Spawn object problem

Hey how is the unity community doing today ive made an exploding car that replaces itself with a burnt on fire debris pile but when i blow the car up it spawns 7 times… this is because of the explosion effect how would i got about making this only happen once or stopping it with out stopping my effect if it spawn into the blowing up car so i need them to stay together so i can throw the debris this is what i need to only run once

void Die (){

	if (deadReplacement) {
		Transform dead = Instantiate(deadReplacement, transform.position, transform.rotation) as Transform;

		// Copy position & rotation from the old hierarchy into the dead replacement
		CopyTransformsRecurse(transform, dead);

static void CopyTransformsRecurse ( Transform src , Transform dst ){
	dst.position = src.position;
	dst.rotation = src.rotation;
	foreach(Transform child in dst) {
		// Match the transform with the same name
		Transform curSrc = src.Find(;
		if (curSrc)
			CopyTransformsRecurse(curSrc, child);


I figured out it was spawning as many times as my bullets hit it before it dies so when i shoot a shotgun at it it makes copys of how many bullets hit it when health hi zero still have the problem anyone have any ideas? on how to make it spawn once instantly and only once after explosion


Usually problems like these are caused because the specific event is fired multiple times per frame (or before the effect executes), causing multiple effects simultaneously. With the event being the death of your car and the effect being the instantiation of the deadReplacement.

The usual way around the issue is to keep track of the objects state. The state is changed when the event is fired and is checked before the effect executes. In your case you would keep track of whether your car “is dead”:

private bool isDead = false;

public void Kill() {
    if (!isDead) {
        isDead = true;

Hope this helps,