Java LibGDX 3d跟随对象或点

Java LibGDX 3d跟随对象或点,java,algorithm,3d,path,libgdx,Java,Algorithm,3d,Path,Libgdx,我无法将对象旋转到方向位置 我需要将ModelInstanceexample代码旋转到point或ModelInstance 但当我使用setToLookAt时,它总是重置我的变换。我需要像“看”这样的东西,而不是设置它,只是看方向 请问我怎么做 变量: private Vector3 position; private ArrayList<Vector3> path; private int currentWaypointId = 0; private Vector3 direct

我无法将对象旋转到方向位置

我需要将ModelInstanceexample代码旋转到point或ModelInstance

但当我使用setToLookAt时,它总是重置我的变换。我需要像“看”这样的东西,而不是设置它,只是看方向

请问我怎么做

变量:

private Vector3 position;
private ArrayList<Vector3> path;
private int currentWaypointId = 0;
private Vector3 direction = new Vector3();
private Vector3 tmpV2 = new Vector3(), tmpV1 = new Vector3();
private float speed;
更新方法:

public void update(float delta){
    if(path != null){
        transform.getTranslation(tmpV2);
        tmpV1 = path.get(currentWaypointId).cpy();

         if (tmpV1.dst(tmpV2) < 2){
             currentWaypointId++;
             if (currentWaypointId >= path.size()) currentWaypointId = 0;
             tmpV1 = path.get(currentWaypointId).cpy();
         }

         direction = (tmpV1).sub(tmpV2).nor();

         transform.translate(direction.scl(speed*delta));
    }
}

感谢您的回答

它是否正确地遵循了路径?您从未设置其旋转,因此无法将其旋转到其方向请查看。派生吃法可用于旋转方向。@Springrbua我正在移动没有旋转的对象。@Xoppa对不起,我弄错了。我重写了一个问题。你可以使用setToRotationVector3 direction,Vector3 face,其中direction是你想看的方向,face是脸,应该朝这个方向看。