hey guys, I’m scripting something like, if the player is dead, will wait some seconds, (3 seconds), I mean, wait to the dead animation complete, and then, reload the scene. Can anybody help me how can I do this?
You can check if a certain animation is playing using:
animation.IsPlaying(“nameOfAnimation”);
or if any animation is playing (is not finished) using:
animation.isPlaying;
if you have set States too your player, you could have something like a Dying State, so when the State equals Dying, you keep calling the Dying() method.
Heres some code that I think should solve your problem, ( I code in C#, so I’m not too sure about this syntax, but you can understand the idea). Hope it’s helpfull to you.
if(player dies){
PlayerState = Dead;
Die();
function Update():void
{
if(PlayerState == Dead){
Dying();
}
}
function Die():void
{
animation.CrossFade("Dying");
}
function Dying():void
{
//make sure the animation that would be playing when this function is called
//is the "Dying" one. It will only enter the if() if the animation has finished
//playing;
if(!animation.isPlaying)
{
//Load scene
Application.LoadLevel("CurrentScene");
}
}
So, er… I’ve made something similar, and it’s going well, but, is there some way to make the animation stop in the last frame?