0

I have the camera's roll, yaw, pitch, x, y, and z, and I need to change the position based off of the WASD keys. For example, If the yaw is 0 and I press W, the x increases by 1 and the z doesn't change. If the yaw is 90 the z increases by 1, and all the values of the yaw 0-360.

I just need a formula to do that. I have a decent idea of how I would change to to move backwards, left, right, etc... I just don't know what it would be.

I looked around and didn't see any solutions that worked, I tried a couple different methods using trig (cos and sin), but I know I need to use a matrix.

Big_Bad_E
  • 947
  • 1
  • 12
  • 23
  • I am still looking for a solution, I have no idea how to do this. I'm all out of ideas. – Big_Bad_E Jun 20 '18 at 02:21
  • see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) when you understand it look at the bottom of the answer there are links with C++ examples of camera and player control (which is what you are doing)... also this might be helpfull (if you want also mouse control for some objects) [OpenGL Drag&Drop in3D](https://stackoverflow.com/a/50908533/2521214) – Spektre Jun 20 '18 at 07:19

1 Answers1

0

This code fixed it for me!

(float)Math.sin(Math.toRadians(yaw));

Its a bit rough around the edges, but its fine.

Big_Bad_E
  • 947
  • 1
  • 12
  • 23