【发布时间】:2015-05-30 11:32:09
【问题描述】:
我通过添加航点为我的 Spatial 构建了 MotionPath。当我做这样的事情时它工作正常
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));
我想通过在这样的方法中放置航点来动态移动它
public void moveSpatial(float x) {
Vector3f currentTranslation = spatial.getLocalTranslation();
path.addWayPoint(currentTranslation.x, 0, 0);
path.addWayPoint(currentTranslation.x + x, 0, 0);
}
在我添加的 simpleUpdate 方法中
spatial.setLocalTranslation(new Vector3f(newX, 0, 0);
在哪里
float newX = currentTranslation.x + x;
现在,动画(平滑移动)正在运行,但是每次我调用 moveSpatial 方法时,空间首先会到达起点 Vector3f(0, 0, 0),然后他正在通过航路点移动。 (0, 0, 0) 是我启动应用程序时为空间设置的位置。我想从空间结束他的运动的最后一个位置开始运动。如何做到这一点?
【问题讨论】:
-
我猜这与您在stackoverflow.com/questions/30479970/… 的其他问题有关?我认为这是解决您的问题的一种奇怪方法。我会尝试为原始帖子贡献一些东西。