Hello. I don’t know why my script isn’t working, when my character hits the collider the HP on the Inspector while in game isn’t changing. This is the script:
using UnityEngine;
using System.Collections;
public class HPScript2 : MonoBehaviour {
public int HP = 100;
public Transform target;
public GUIText healthText;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
healthText.text = System.Convert.ToString (HP);
}
void HPLose(Collider col)
{
if(col.tag == "trap")
{
HP -= 10;
}
}
}
I apply this script to my player controller. Thank you.
Or OnTriggerEnter, with a trigger collider
– Seth-McCumber