Move a object with animation

Hello, I wondered how we had to do to make animations? meaning you move an object without the keyboard. click on a place and purpose of this position is with a displacement



if you could help me



thanks!

Animations are made in a 3d modeling program. jme recommends blender.

No Iā€™m talking about a movie like this: my object X is moving from point A to B in a time of 5 seconds for example.

use [java]Vector3f newLocation = FastMath.interpolateLinear(float amount, Vector3f start, Vector3f end); // (might be amount at the end of arguments)

spatial.setLocalTranslation(newLocation);[/java] where amount goes from 0 ā†’ 1, 1 being the end, and increment amount in an update loop.

yeah, and using the Cinematics API for jm3.

1 Like
wezrule said:
use [java]Vector3f newLocation = FastMath.interpolateLinear(float amount, Vector3f start, Vector3f end); // (might be amount at the end of arguments)
spatial.setLocalTranslation(newLocation);[/java] where amount goes from 0 -> 1, 1 being the end, and increment amount in an update loop.

Thank you for your response. but it is only moving the object without animation!


glaucomardano said:
yeah, and using the Cinematics API for jm3.


Thank you to you! In fact I had not thought of that! everything works I put my code if anyone needs help (the tutorial is there for that if not)

[java] Cinematic cinematic = new Cinematic(object1, 5);
cinematic.addCinematicEvent(0, new PositionTrack(object1, object1.getLocalTranslation().add(500f, 0,0 ), 5, LoopMode.Loop));
stateManager.attach(cinematic);
cinematic.play();[/java]

and tuto : https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:cinematics

Bye !
1 Like