I am making a game, and the body has a separate object for the head, i wanted to make the head a weaker point, but whem i clonned my prefab and shooted one of them all the other clones got destroyed;
body:
public int VidaTotal;
public static int Vida;
void Start () {
Vida = VidaTotal;
}
// Update is called once per frame
void Update () {
if(Vida <= 0){
Destroy(this);
}
}
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.CompareTag(“bullet”)){
Vida --;
Destroy(col.gameObject);
}
}
Head :
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.CompareTag(“bullet”)){
Enemy.Vida = - 1;
Destroy(col.gameObject);
},