Hello,
I have an animation on my scene of a safe door opening. The animation is being controlled from another source, and for some reason, the animation keeps looping. I only want it to play once. Here is a snippet of my script:
var safeDoor : GameObject;
if(codeCorrect == false){
safeLight.light.color = Color.red;
}
else {
safeLight.light.color = Color.green;
safeDoor.animation.wrapMode = WrapMode.Once;
safeDoor.animation.Play("OpenDoorSafe");
}
}
What am I doing wrong? I also set the WrapMode to Once in the inspecter of the animation file.
Thanks
--- Updated Script ---
private var playAnimationSafeDoor : boolean = true;
var safeDoor : GameObject;
function Update(){
if(codeCorrect == false){
safeLight.light.color = Color.red;
}
else {
safeLight.light.color = Color.green;
if(playAnimationSafeDoor == true){
AnimationSafeDoor();
playAnimationSafeDoor = false;
}
}
}
function AnimationSafeDoor(){
safeDoor.animation.wrapMode = WrapMode.Once;
safeDoor.animation.Play("OpenDoorSafe");
playAnimationSafeDoor = false;
return;
}
And it still loops ...?