Well I’ve been struggling for a while but I still can’t figure out how to get the wings to tilt when the flying object turns.
This video shows how the tank’s steering is currently meeting my expectations.
@Override
protected void controlUpdate(float tpf) {
if (spatial != null) {
if (i < move.size() - 1) {
Vector3f currentPoint = spatial.getLocalTranslation();
Vector3f nextPoint = move.get(i + 1);
// Calculate the step of the node towards the next point
Vector3f step = nextPoint.subtract(currentPoint).normalizeLocal().multLocal(tpf).multLocal(50f);
Vector3f directionToTarget = nextPoint.subtract(currentPoint).normalizeLocal();
Quaternion rotation=spatial.getLocalRotation();
targetQua.lookAt(step, new Vector3f(0,1,0));
rotation.nlerp(targetQua, 0.1f);
float GoalAngle = Math.abs(spatial.getLocalRotation().dot(targetQua));
// System.err.println("相似度:" + GoalAngle);
spatial.setLocalTranslation(currentPoint.add(step));
// Check if you have reached the next point getLocalTranslation
float distanceToNextPoint = spatial.getWorldTranslation().distance(nextPoint);
// System.err.println(distanceToNextPoint);
if (distanceToNextPoint < 0.2f ) {
//If the next point has been reached, update the current path index
i++;
}
}
}
}
I’m currently using this code to move.
Use this code to complete the turn
Quaternion rotation=spatial.getLocalRotation();
targetQua.lookAt(step, new Vector3f(0,1,0));
rotation.nlerp(targetQua, 0.1f);
How do I tilt while steering and level when I’m done(Steer like an aeroplane.)?
//Please point out any confusion about my questions.