Hi, I’m having a problem where all of the game objects with the health script get destroyed, not just one specific instance. I know why this has happened, but don’t have a solution. If I’m correct it’s because the scripts changes a value for all instances that it’s attached to.
The health script:
using UnityEngine;
using System.Collections;
public class health : MonoBehaviour {
public float maxHealth;
public float minHealth;
static float currentHeath;
void Start() {
currentHeath = maxHealth;
}
void Update() {
if (currentHeath < minHealth) {
Destroy(this.gameObject);
}
}
public void takeDamage(float Damage) {
currentHeath = currentHeath - Damage;
}
}