In order to implement triggered sound into my video game environment I require three scripts depending on how I want the sound to trigger. The Scripts are as follows:
Trigger Sound:
function OnTriggerEnter()
{
audio.Play();
}
function onTriggerExit()
{
audio.Stop();
}
Click to trigger sound:
function OnMouseDown()
{
audio.Play();
}
Collision sound:
function OnCollisionEnter()
{
audio.Play();
}