I’m trying to make it so when it hits other colliders with matching tags, it will do as follows… and it only does it say 1 out of 4 hits?
using UnityEngine;
using System.Collections;
public class heartSystem : MonoBehaviour {
public float healthAmount;
public GameObject heart;
public Transform heartSpawn;
public float countDown;
public GUIText health;
// Use this for initialization
void Start () {
countDown = 20;
healthAmount = 3;
}
// Update is called once per frame
void Update () {
countDown -= Time.deltaTime;
if (healthAmount <= 0) {
Time.timeScale = 0.25f;
}
if (countDown <= 0){
Instantiate (heart, heartSpawn.position, heartSpawn.rotation);
countDown = 20;
}
health.text = "Lives: " + healthAmount;
}
void OnTriggerEnter (Collider other){
if (other.tag == "Heart") {
healthAmount += 1;
}
if (other.tag == "Asteroid") {
healthAmount -= 1;
}
}
}