okay because the overriding doesn't seem to work with my code.
Imagine I have 2 animation that could be active at the same time, one random stance animation (stances are for example idle, walk, or hanging (as described above)) and a skill animation (fireball, hit,...).
My goal is that regardless of which stance animation is active, the skill animation should override the stance animation.
I tried the approach with an AnimationState object, but for some reason the mixing time between 2 animations was longer as when I just use 2 animation objects.
The documentation says that the AnimationState class could be used to make crossfading between animations more convenient. So I tried again my previous method, using animations directly and it works... partially
stance_animation.apply(skeleton, lastTime, time, loop, null);
if(skill_animation != null) //skill animation is null when inactive
skill_animation.apply(skeleton, lastTime, time, loop, null);
Applying them directly in a row works fine but there is no mixing at the moment.
Adding mixing leads to a behaviour where the skill animation doesnt run to the end.
if (time < mix_time)
stance_animation.mix(skeleton, lastTime, time, false, null, time
/ mix_time);
else
stance_animation.apply(skeleton, lastTime, time, loop, null);
if (skill_animation != null){
if (time < mix_time)
skill_animation.mix(skeleton, lastTime, time, false, null, time
/ mix_time);
else
skill_animation.apply(skeleton, lastTime, time, loop, null);
}
I would prefer a solution by using 2 animation objects instead of one AnimationState.
Maybe I missed something. Could it be incorrect applying stance_animation first and then mixing with skill_animation?
Giving up the second mix snippet (skill_animation.mix()) leads to a better solution 🙂
SOLVED: for some reason the animation-based approach (just using the Animation class) didn't work in my "special" case, so I went back and spent more time in the AnimationState approach. Now it works fine. In addition, I had to divide the mixing time by 2 to get the same mixing time as with the animation-based way (but I don't no why).
AnimationStateData data = new AnimationStateData(skeleton.getData());
data.setDefaultMix(MIX_TIME / 2);
animation_state = new AnimationState(data);