I’ve build a MotionPath for my Spatial by adding waypoints. It is working fine when I do something like this
path.addWayPoint(new Vector3f(0, 0, 0));
path.addWayPoint(new Vector3f(2, 0, 0));
path.addWayPoint(new Vector3f(4, 0, 0));
path.addWayPoint(new Vector3f(6, 0, 0));
I wanted to move it dynamicly by putting waypoints in method like this
public void moveSpatial(float x) {
Vector3f currentTranslation = spatial.getLocalTranslation();
path.addWayPoint(currentTranslation.x, 0, 0);
path.addWayPoint(currentTranslation.x + x, 0, 0);
}
and in simpleUpdate method I’ve added
spatial.setLocalTranslation(new Vector3f(newX, 0, 0);
where
float newX = currentTranslation.x + x;
now, the animation (smooth move) is working BUT every time when I invoke moveSpatial method the spatial first goes to starting point Vector3f(0, 0, 0) and then he is moving by waypoints. the (0, 0, 0) is position set for spatial when I start the application. I would like to make the movement from the last position where spatial ended his movement. How to do this ?