I want to know if it’s possible to pause an animation during its execution?
For exemaple i have an animation of an elevator going up and down, when players rich the top and get out of the elevator the elevator stops and when player get back again in the elevator its start the rest of the animation making the elevator go down.
example:
var elevator : GameObject;
function Start(){
//Here i've stopped all the animations at the beggining of the game;
animation.Stop();
}
function OnTriggerEnter(){
//It will play the animation when player gets the elevator;
elevator.animation.Play("elevator");
}
function OnTriggerExit(){
//It will stop the elevator when player gets off
animation.Pause();
//I'm using animation.Stop() in my script today, but when player get back to the elevator it begin the animation all over again, not where it stopped.
}
Hello, I know this is many many years late but this is for everyone that wants an easy way to pause an animation.
If you are using an animator component and place it on a script such as public Animator anim;
When you want to pause the animation you can say anim.speed = 0; and if you want to make it back to the normal speed you can type anim.speed = 1;