Attach a script on your colliders and make a GUIScriptName gSN variable. OnTriggerEnter(), check the tag of the collider (let's call it col). If col.gameObject.tag == "Enemy" then access the coordinates of your GUI element (coordinates/ fill amount/ text display - anything you're using).
e.g.
if (gSN.myHealth - damage > 0) {
gSN.myHealth -= damage;
}
else {
//dead
}
In the GUI script, your e.g. GUIText will be displaying the current health of your player, so it will already be updated on the next frame.
↧