Hi all,

as you already know, im making a new game. Im having trouble with the rotations of the turrets. I was hoping to make the turret follow the plane’s position by rotation.

Does anybody know how to do this. As in find the angle between two points.

PS. I dunno if I can use trig, because it might not be a rightangled triangle.

any ideas?

Calculate the angle between the turret and the ship. Set the turrets rotation quaternion to the axis angle, where axis is (0,1,0) (if Y is your up axis), and your angle between ships.

target.x += 0.05f;
target.y += 0.05f;

float x = target.x - rot.getLocalTranslation().x;
float y = target.y - rot.getLocalTranslation().y;
rotCounter = (float)(Math.atan2(y, x));
rotQuat.fromAngleAxis(rotCounter, axis);

There it is! The turret now follows the ship. Hurray!