- Home /
Play Animation A after Animation B ends
How do you play one animation (Loop) after the other (Once) finishes?
Answer by dorpeleg · Feb 18, 2013 at 08:54 PM
You can do something like this:
gameObject.animation.Play("Once");
AnimationPlayed = true;
if (AnimationPlayed && !gameObject.animation.isPlaying("Once"){
gameObject.animation.Play("Loop");
}
I'm using similar code all the time.
Put this:
gameObject.animation.Play("Once");
AnimationPlayed = true;
anywhere you want that animation to play.
Put this:
if (AnimationPlayed && !gameObject.animation.isPlaying("Once"){
gameObject.animation.Play("Loop");
AnimationPlayed = false;
}
in the update funcation.
should .CrossFadeQueued be able to do something like this? it seems a resource-hog to have to use Update just to check if an animation has finished playing..
animation.PlayQueued("loop", Queue$$anonymous$$ode.CompleteOthers);
that should work.
if it still doesn't, maybe you should show us your code so we can understand.
what if you have both idle loop and walking loops? Your code seems to only work for characters that by default go back to infinite idle.. prevents walk animation from looping.
Answer by M_Joe · Feb 19, 2013 at 04:17 AM
You can ues Animation.CrossFadeQueued(animationName) or Animation.PlayQueued(animationName).
That doesn't seem to work... Or maybe I'm not using it right?
Answer by Ankit Priyarup · Mar 07, 2013 at 07:40 AM
You can add a float value in which the user will input duration and use wait second for playing that and destroy the old one
Your answer
Follow this Question
Related Questions
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers
Can I make animations snap to a frame? 1 Answer
How to select an animation clip by index number? 7 Answers
Left can Animate but right cannot. Why? 0 Answers