【问题标题】:How to make continuous MotionPath?如何制作连续的MotionPath?
【发布时间】: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) 是我启动应用程序时为空间设置的位置。我想从空间结束他的运动的最后一个位置开始运动。如何做到这一点?

【问题讨论】:

标签: animation jmonkeyengine


【解决方案1】:

我找到了解决方案,它真的很简单 :) 为了防止这种奇怪的行为,需要添加 localTranslation 的路点侦听器更改。比从上一个当前位置添加新航路点时,它将从结束的地方开始

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    相关资源
    最近更新 更多