UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"decrease health bar when player collides with hurdle"
public class Healthbar : MonoBehaviour { public AudioClip destSound; void OnTriggerExit(Collider other) { if(other.gameObject.name == "Circle") { HealthBar.health -= 1f; AudioSource audio = GetComponent<AudioSource> (); audio.PlayOneShot (destSound); other.gameObject.SetActive (false); } } }