Hi
I have created a box which runs some code when a player enters the trigger point.
Everything works apart from the audio will not play.
I have tested the audio with play on awake and it runs fine then, i just dont seem to be able to get it to play when i want it to.
Anybody see what im missing?
Thanks
public class healthPowerUp : MonoBehaviour {
public int healthUp = 50;
AudioSource Health_sound;
GameObject player;
PlayerHealth playerhealth;
// Use this for initialization
void Awake () {
player = GameObject.FindGameObjectWithTag ("Player");
playerhealth = player.GetComponent<PlayerHealth> ();
Health_sound = GetComponent<AudioSource> ();
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject.tag == "Player")
{
Health_sound.Play();
Debug.Log ("played");
playerhealth.AddHealth (healthUp);
Destroy (gameObject);
}
}