- Home /
Check to see if animation is playing
Hey guys, I want to check if the animation is finished playing then destroy the game object.
public void KillEnemy(){
//state = state
enemyIsDead = true;
state = State.FLEE;
combatState = CombatState.LOSE;
animation.Stop();
Debug.Log(state);
animation["death"].layer = 2; //all animations start at 0.
animation["death"].wrapMode = WrapMode.Once; //jump once
animation["death"].speed = 1f; //all animations start at 0.
animation.Play("death");
}
So you can see that I stop the animation, and then play the next animation.
I have tried "animation.isPlaying" but it did no work, maybe It wasn't implemented properly.
if(animation("death") has finsihed playing{
then destroy the object
}
Thank you.
Have you tried using coroutines? You set it up for the duration of the sound, then get it to set a bool value e.g. trackFinished = true;
I tried using this from other examples, how ever it crashes since you have to pass an animation, and I don't think it's possible to declare animations to a variable (i've tried and researched).
Alternatively, you can invoke a method in animation clip.
Answer by EggQuiz857 · Nov 28, 2014 at 06:02 AM
try typing this and you should get something 'animationisplaying' it is a if statement good luck. Survival of the fittest
Your answer
Follow this Question
Related Questions
How to get an animation script working? 1 Answer
Animation Not Playing 1 Answer
I need help writing an animation script for a Bow and Arrow weapon 1 Answer
my animation script does not work 0 Answers
animating character 1 Answer