- Home /
audio will not play if trigger collides
hey here is my question i have my trigger finaly working now but i add a script for the sound of the doors opening bu unity says that it is not a proper version of unity audio source engine or donthing can you help me?
var triggerTarget : GameObject;
function OnTriggerEnter (other : Collider) { triggerTarget.animation.Play("Take 001"); audio.Play("03"); }
Answer by Borgo · Jan 25, 2011 at 04:09 PM
You are trying to pass a String to the Play function.
The play function don't need to receive a var...
Just use:
var audio1 : AudioClip; var audio2 : AudioClip;
function OnTriggerEnter (other : Collider) { audio.clip = audio1; audio.Play();
//Play another sound
audio.clip = audio2;
audio.Play();
}
Don't forget to have a AudioSource component to your object and attach the sounds in the inspector.
Answer by Jessy · Jan 25, 2011 at 04:10 PM
AudioSource.play does not take a string parameter. Why are you providing it?
Your answer
Follow this Question
Related Questions
Multiple Audio Sources On One Object 0 Answers
Problem with streaming audio and play in trigger area 0 Answers
Play Audio Sound OnTriggerEnter 2 Answers
Stream multiple audio files 1 Answer
Need help on audio trigger. 2 Answers