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. Unfortunately, it still doesn’t work. The next level was never being loaded because the animation still played repeatedly for some reason…