Hi, I was trying to make a script for a SciFi like sliding door, I created 2 animations, one of which is the door just moving right, and the the other puts it back into place. My script uses OntriggerEnter and everything works fine except that as soon as I enter the collider, the door constantly opens and closes until I leave? The sound also constantly plays as if it actually is constantly opening and closing.
Here is my script if there is a problem in it:
#pragma strict
var DoorOpenAnimation : AnimationClip;
var DoorCloseAnimation : AnimationClip;
var DoorOpenSoundEffect : AudioClip;
var DoorCloseSoundEffect : AudioClip;
function Start () {
}
function Update () {
}
function OnTriggerEnter (other : Collider)
{
animation.Play("DoorOpenAnimation");
audio.PlayOneShot(DoorOpenSoundEffect, 1.0);
}
function OnTriggerExit (other : Collider)
{
animation.Play("DoorCloseAnimation");
audio.PlayOneShot(DoorCloseSoundEffect, 1.0);
}
Thank in advance for anyone who will help.