Hello everyone,
I can’t seem to figure this one out. I want to have my player (wich is using bullet and thus has a vector3f for a view direction) to be rotated around Y with two keys.
Before this, it worked via the camera:
viewDirection.set(camera.getDirection().x, 0, camera.getDirection().z);
Now I need to have a rot value that I can increase or decrease with two keys:
{
rot += 90 * FastMath.DEG_TO_RAD * tpf;
}
else if(key.equals("TurnRight") && isPressed)
{
rot -= 90 * FastMath.DEG_TO_RAD * tpf;
}```
This basically says that I want the rotation speed to be 90 degrees per second. I now need to convert this into a view direction vector.
This is what I have until now, but it's not working:
```float[] angles = new float[3];
System.out.println(rot);
Quaternion q = new Quaternion();
// q.lookAt(new Vector3f(0, rot, 0), Vector3f.UNIT_Y);
q.fromAngleAxis(rot, Vector3f.UNIT_Y);
angles = q.toAngles(angles);
System.out.println(Arrays.toString(angles));
viewDirection.set(angles[0], angles[1], angles[2]);
System.out.println(viewDirection);```
Any ideas?