How to reverse an animation

Dear all,

I have a walk animation. But when the user press the key “S”, I would like to play the reverse walk animation. Can someone explain me how it is possible ?
I try with a animChannel.setSpeed(-1.0f) (negative value) but of course, it does not work…

Thank a lot.

It looks like your only option is:



There is a loopmode called “Cycle” that the docs say “cycles back and forth”

I have no idea if trying to play the second half of this animation would work or if you could work thatin

My only other suggestion is to try to put a speed of -1

Neither of these are tested and just a guess

1 Like
@BigBob said: There is a loopmode called "Cycle" that the docs say "cycles back and forth"

I remember reading this a ways back, but could only make it go on the forth part >.<

I wonder if it actually does cycle into both directions… and how you would do that.

I have already tried the Cycle loopmode and to put the speed of -1. But no one works :frowning:

So, I think I will use the only solution:

And see if there is a way to do it simply with Blender…

There is no way to play an anim backward.
The Cycle mode play the anim forward, then backward, but you can’t start with backward.

I think I did it in Monkey Trap but I feed my own frame time in for all of the animations… so I could run it in whatever direction I wanted.


pspeed that is brilliant idea :slight_smile:


sorry to dig this one
but how exactly do you “feed your own frame time” ??

I need to stp an anim (canceled by the user) to play it in reverse at the precise time it stopped


[edit: i guess setTime would do the trick, but a more user friendly way would be neat, I mean if it can play it backward that way, it should be the engine dealing with this with a LoopMode.Backward enum]

You can look at Monkey Trap if you really want to dig in:

But I suspect glancing at JME’s javadoc might be more helpful.

…see if you can figure out which method would set the animation time…

well I use setTime so far, but as I iterate over animation.speed, it seems to go faster, that’s why I think it would be better if the engine itself was dealing with this. thx anyway :smile:

I have no idea what that means.
animationTime -= tpf;
…not sure what the issue is.

reverses bone animation:

 Track[] tracks = myAminControl.getAnim("myAnim").getTracks();
    for (Track track : tracks) {

        Quaternion[] roatations = ((BoneTrack) track).getRotations();
        Vector3f[] scales = ((BoneTrack) track).getScales();
        Vector3f[] translations = ((BoneTrack) track).getTranslations();
        Vector3f tempVectror3f;
        Quaternion tempQuaternion;
        for (int i = 0; i < (roatations.length / 2); i++) {
            tempQuaternion = roatations[i];
            roatations[i] = roatations[roatations.length - 1 - i];
            roatations[roatations.length - 1 - i] = tempQuaternion;
        for (int i = 0; i < (scales.length / 2); i++) {
            tempVectror3f = scales[i];
            scales[i] = scales[scales.length - 1 - i];
            scales[scales.length - 1 - i] = tempVectror3f;
        for (int i = 0; i < (translations.length / 2); i++) {
            tempVectror3f = translations[i];
            translations[i] = translations[translations.length - 1 - i];
            translations[translations.length - 1 - i] = tempVectror3f;
        ((BoneTrack)track).setKeyframes(((BoneTrack)track).getTimes(), translations, roatations, scales);