Hello I need help with a low health script. I have a gameobject with a health text value and I am trying to play a sound on low health. The script I am trying to use below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour {
public Text health;
public AudioSource mysound;
void Update () {
if (health=5) {
mysound.Play();
}
}
I drag my playerhealthtext into the public health field create an audiosource but I can’t get it to work. Any ideas how I can implement this?