- Edited
Reset Track animation
So the normal animation occurs on track 0. I shoot/mix animation on track 1 on loop. The arm bone attachment changes to a gun.
When done shooting, how do I reset the animation so track 1 doesn't exist?
You have a few options:
You can call AnimationState clearTrack
(or clearTracks
) will stop the animation, but the skeleton will get left in whatever pose it was in.
You can set TrackEntry trackEnd
to Animation duration
. The animation will be removed and the skeleton reset to the setup pose.
You can call AnimationState addEmptyAnimation
to queue an empty animation, with optional mix duration. This allows you to have the animation transition to the setup pose when finished, rather than snap abruptly to the setup pose like it would with trackEnd
. For tracks > 0, the animation will mix out (giving control back to the animations below) instead of mixing to the setup pose.
There is also AnimationState setEmptyAnimation
which is used to set the current animation to an empty animation rather than queue it. setEmptyAnimation
is usually used to mix from the setup pose (or the underlying animations for tracks > 0) to an animation. Eg:
state.setEmptyAnimation(0, 0.2);
state.addAnimation(0, "walk", true, 0);
state.addEmptyAnimation(0, 0.2, 0);
This will mix from the setup pose to walk, then from walk back to the setup pose. If this were run on a track > 0, it would mix in the walk animation, then mix it out. You can see this in the IK demo, drag the red circle and when you release, spineboy quickly shoots at that position, then the shoot animation is mixed out, resuming the idle animation.