- Home /
Animation at the end of the level
Hi. I have a game with one animation in it. The animation should be played at the end of each level. How to connect the script with the animation? For now, the animation is played at the begining of the level and then I can't move my player.
Can somebody help me fix this?
Comment
Answer by Hullu · Jul 28, 2014 at 01:49 PM
In animation component, uncheck "Play Automatically".
function LoadNextLevel (level_to_load : int) {
animation.Play(animation.clip.name);
yield WaitForSeconds (animation.clip.length);
Application.LoadLevel (level_to_load);
}
This plays the animation and waits for it to end before loading new level.
EDIT:
The first code is in javascript, this is in C# :
IEnumerator LoadNextLevel (int level_to_load) {
animation.Play(animation.clip.name);
yield return new WaitForSeconds(animation.clip.length);
Application.LoadLevel(level_to_load);
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Animation disturbing circular rotation 1 Answer
Animation at the end of the level 1 Answer
How to Serialize an AnimationState 0 Answers