Question by 
               VeryPoorProvider · Mar 17 at 09:03 PM · 
                c#unity 5gameobjectdestroy  
              
 
              How to destroy only a clone in Unity 3d?
I have a tank:
 using UnityEngine;
 
 public class TankScript : MonoBehaviour
 {
     public static int health = 100;
     public GameObject tankItemPrefab;
 
     void Update()
     {
         if (health <= 0)
         {
             Instantiate(tankItemPrefab, transform.position, transform.rotation);
             Destroy(gameObject);
         }
     }
 }
When his health drops to zero, he must destroy himself and create a tankItem at the place of his death. Everything works, but for some reason all tanks are destroyed. How to fix it?
               Comment
              
 
               
              Thats the Right answer. For all your Tanks you have only one Health variable. As soon as one Tank Health goes 0 all other Tanks doing it aswell. Change the value away from Static and it should work fine.
Your answer
 
 
             Follow this Question
Related Questions
How to destroy on exiting PlayMode/EditMode? 1 Answer
how do i collide and kill the enemy while pressing space Unity 5 C# 2 Answers
Unity5/C# beginner here! Need some scripting help :) <3 1 Answer
Destroyed instance of Prefab, can't spawn it back. 1 Answer
Remove Object from Game after Collision with Player (Unity 5.2.3f1) 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                