Hi,
I am attempting to implement plane rotation a bit like the game AirRivals, where moving the cursor upwards causes the plane to pitch upwards, with a fixed camera angle behind the plane.
To rotate the plane on the yaw axis, I used this code:
float x = (Display.getWidth() / 2) - Mouse.getX();
x/=500;
Vector3f cAng = new Vector3f(0, x, 0);
clamp(cAng); //Clamp between value of 0 and 1
player.setAngularVelocity(cAng);
This works successfully, but when I try and add pitch to this, it completely breaks down.
float y = (Display.getHeight() / 2) - Mouse.getY();
float x = (Display.getWidth() / 2) - Mouse.getX();
y/=500;
x/=500;
Vector3f cAng = new Vector3f(y, x, 0);
clamp(cAng);
player.setAngularVelocity(cAng);
The issue here, as you can see in the GIF, is that when I pitch the plane up or down, the plane also starts to roll.
The plane pitch acts correctly (nose up or down as expected on a real plane) if I do NOT ever change the yaw. If I bash into the ground and get the yaw changed, the plane starts rolling around again.
The plane yaw always seems to work correctly, and always appears to turn it in the direction of the wingtips no matter the pitch/roll of the plane.
Basically, long story short - Changing the pitch works, changing the yaw works, but they do not seem to work together.
What can I do to solve this issue?