I want to create an invisible wall that you can pass-through both ways and play’s Audio when they pass through.
Example: a character walks into a room and then they hear a band but they can go outside the same way and the sound doesn’t play again.
I’m also looking into randomising sound within an album of specific sounds so instead of a bang the player will hear a cat or glass smashing.
Make Empty game object attach box collider and audio source. Set in box collider that it is trigger. And write script for example :
var once : boolean; // play sound only once
var sounds : AudioClip[];
function OnTriggerEnter ( other : Collider) {
if (other.gameObject.CompareTag("Player")){
audio.clip = sounds[Mathf.Round(Random.Range(0,sounds.length-1))];
audio.Play();
if (once) Destroy(this);//Destroy this script
}
}