Load Level after Animation is finished

I have been trying to figure this out.
I have a scene, which is basically just the Main Camera moving around. What i want is while this animation is running i want to do a:

Application.LoadLevelAsync (loadLevel)

and when the animation is done, I want the level to start.
Is it possible?

yes its possible make the animation first then a cube or a empty game object when the camera hits tht game object make it so the game loads the next level thts wht i have done for my mmorpg cutscene im glad i can help. if u can help me ill be happy i cant make an animation play by clicking a button =( like if u click r on keyboard u reload the gun for my fps =( plz help if you can.

This is probably one of the cleaner methods. It will require a Class surrounding it, as well as an Animation Component on the same Object and an appropriate animation and level name.

It should be pretty modifiable and customizable should you need to check other animation components or need to split it up between gameobjects.

It just plays the animation, waits the duration of the animation, then loads the level.

public string animName;
public string levelName;

public void Play()
{
animation.Play(animName);
StartCoroutine(LoadAfterAnim());
}

public IEnumerator LoadAfterAnim()
{
yield return new WaitForSeconds(animation[animName].Length);
Application.LoadLevelAsync(levelName);
}
1 Like