Hi, I have used the script, which I called healthEffects, and applied it to two different objects (a sphere and a cylinder). My idea is to have some collisions that give points, and some that take them away. I have given a negative pick up amount to the sphere, and a positive to the cylinder. They both have isTrigger ticked, and they both have colliders. The sphere works, but the cylinder does not. I have tried putting the cylinder above the sphere in the hierarchy, but that doesn’t change anything. The player is tagged with ‘player’. Any ideas?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class healthEffects : MonoBehaviour {
public Text healthText;
public int pickupAmount = 10;
public int currentHealth = 50;
// Use this for initialization
void Start () {
healthText = GameObject.Find (“Text”).GetComponent ();
}
// Update is called once per frame
void Update () {
healthText.text = “Health ” + currentHealth;
}
void OnTriggerEnter (Collider col)
{
if (col.gameObject.tag == “Player”)
{
currentHealth += pickupAmount;
}
}
}