Animation keeps playing?

Hi guys,

I am having a problem with animation. In my game, if you collect enough item, an animation saying"move to next level" would happen and move to the next scene automatically after a few seconds. I set the animation to only run it once, not loop. However, when I play the game, the animation instead plays repeatedly when the action being initialized. I really don’t know what happened that makes the animation being called over and over again…

Here is the code:

var howmanyGUI : GUIText;
var howmanyLeft = 1;
var howmanyOnce = 1;


function Start () 
{
    ANS = 2;
}

static var ANS = 2; 

function Update () {
	if (ANS == 2) {
	
	howmanyLeft = howmanyOnce;
		howmanyGUI.text = "" + howmanyLeft;
		
	}
	if (ANS == 1) {
	
	howmanyLeft = howmanyOnce - 1;
		howmanyGUI.text = "" + howmanyLeft;
		
		
		Delaymove();
		 
	}
}

function Delaymove()
{
	
	animation.Play("success");
	
	yield new WaitForSeconds(3);
	Application.LoadLevel(3);
	
}

Thanks for your help!!

var getTime : float;

function Awake (){

getTime = animation[“success”].normalizedTime;

}

function Delaymove()
{

if(getTime <= 0){//start and play once till load
animation.Play(“success”);
}

if(getTime >= 1){//If animation is over load
Application.LoadLevel(3);
}

}

Thanks for your help. Unfortunately, it still doesn’t work. The next level was never being loaded because the animation still played repeatedly for some reason…

var getTime : float;

function Delaymove()
{

getTime = animation[“success”].normalizedTime;

if(getTime <= 0){//start and play once till load
animation.wrapMode = WrapMode.Clamp;
animation.Play(“success”);
}

if(getTime >= 0.96){//If animation is over load
Application.LoadLevel(3);
}

}

Try that, also do a print out of getTime and see where your animation maxes out at. This should work…

Thanks it works!!! Nice!!!