I am using the script(javascript) below to make the door open when the player enters the trigger. It works, but when I reenter the trigger area, the animation starts again, and it is weird to see the door starting the animation again. Therefore, i would like to leave the door open forever. Should I kill the script? I can’t kill the gameobject.
Thanks in advance!
var MovingWall : AnimationClip;
function OnTriggerEnter (player : Collider) {
if(player.tag=="Player")
GameObject.Find("MovingWall").animation.Play("MovingWall");
}
function OnTriggerExit (player : Collider) {
if(player.tag=="Player")
GameObject.Find("MovingWall").animation.Stop("MovingWall");
}