Hi
My scene consists of a room and when a trigger is activated an audio clip is played, now would it be possible to also attach a script to this trigger which would activate an animation when the audio clip has finished playing?
Basically I want to have the door to the room open once the audio clip has finished playing.
Any help/tips would be amazing
Thank you
Use the audio.PlayOneShot to start your audio, then check in an update function to see if it is finished. The only other key would be to use a state to see if it should have started
var myClip : AudioClip;
private var audioState=false;
function Update(){
if(audio.isPlaying!=audioState audioState){ DoEvent();}
audioState=audio.isPlaying;
}
function OnTriggerEnter (other : Collider) {
if(other.name=="Player")audio.PlayOneShot(myClip);
}
I don’t completely understand, sorry I am very new to scripting. Would it be possible to just control the animation? for example could I change my trigger animation script so that it has a delay?
This is how my simple script looks for just animating the door opening
var myBox : Animation;
function OnTriggerEnter( other : Collider){
if(other.gameObject.name == "Player"){
myBox.Play();
}
}
Now would it be possible to add to this script so that the door doesn’t open as soon as it’s corresponding collider is triggered? Instead when collision is detected the animation plays after 1 minute.