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.
http://hub.jmonkeyengine.org/javadoc/com/jme3/animation/AnimChannel.html
It looks like your only option is:
[java]
animChannel.setAnim(“TheBackwardsWalkAnimationIMadeInBlender”);
[/java]
=(
BigBob
June 11, 2014, 1:35pm
3
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
So, I think I will use the only solution:
[java]animChannel.setAnim(“TheBackwardsWalkAnimationIMadeInBlender”);[/java]
And see if there is a way to do it simply with Blender…
nehon
June 17, 2014, 6:17am
6
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.
pspeed
June 17, 2014, 7:37am
7
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.
Hi
pspeed that is brilliant idea
-Tommi
Harlock
February 10, 2015, 2:17pm
9
hello,
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
thanks
[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]
pspeed
February 10, 2015, 2:50pm
10
You can look at Monkey Trap if you really want to dig in:
So, about four weeks ago I started writing a “simple” maze RPG rougelike using whatever existing models and stuff I could find. This was supposed to be kind of an example of a more complicated ES-based game than Asteroid Panic while also making a good framework to implement networking.
…then the project kind of took on a life of its own and became a way to test a bunch of ideas out. I should have guessed that when after the first two nights I already had a title screen and had written some ambi…
But I suspect glancing at JME’s javadoc might be more helpful.
http://javadoc.jmonkeyengine.org/com/jme3/animation/AnimChannel.html
…see if you can figure out which method would set the animation time…
Harlock
February 10, 2015, 3:04pm
11
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
pspeed
February 10, 2015, 3:08pm
12
I have no idea what that means.
animationTime -= tpf;
channel.setTime(annimationTime);
…not sure what the issue is.
zmogz1
June 20, 2015, 8:21pm
13
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);
}
2 Likes