Hello, thanks in advanced for any answers. So im making a game where I have creatures that spawn (using instantiate) and I have a kill counter, but the counter only counts to one, when I kill the first enemy, then it just stops counting. I think its because every copy starts counting again from zero. Here is the code that goes into my enemy (its also a health script):
using UnityEngine;
using UnityEngine.UI;
public class health : MonoBehaviour
{
public float hitpoints = 100f;
public Text countText;
int count;
public void Start()
{
count = 0;
}
public void recievedamage(float amt)
{
hitpoints -= amt;
if (hitpoints <= 0)
{
PlusPoints();
Die();
}
}
void Die() {
Destroy(gameObject);
}
void PlusPoints()
{
count = count + 1;
countText.text = "Kills: " + count.ToString();
Debug.Log(count);
}
}