Kiamb
1
My current script is
using UnityEngine;
using System.Collections;
public class AudioTrigger : MonoBehaviour {
public AudioSource source;
public AudioClip clip;
// Use this for initialization
public void Awake () {
source = GetComponent<AudioSource> ();
}
// Update is called once per frame
public void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag ("Player")) {
source.Play ();
}
}
}
How Would I go about playing it once when triggered then disabled forever.
Simple. Use a boolean.
private bool canRunAudio = true;
public void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag ("Player") && canRunAudio) {
canRunAudio = false;
source.Play ();
}
}