2 Answers
2

You need to find a vector that points in the direction the camera is looking and then multiply this vector by your forward movement speed.

So you need to create a Matrix that rotates a Vector x-degrees around the Y-axis. Now I don't know what framework you're using (it just says java in your tags) so I'll just give some sample code that you need to adapt:

Now if you're making a FPS you might also want to add strafing, this can be done easily by taking the forward vector, and rotating it another 90 degrees, you then have the 'left' vector which you can add as above the player's position where speed is 1 when 'strafe-left' is pressed, -1 when 'strafe-right' is pressed and 0 when nothing is pressed

You can also get the left vector by using the cross vector of the forward vector and the up vector (0,1,0).

In my example x is left-right, y is up-down, z+ screen to you z- screen to 'inside' of screen.

Edit: important note, you should always calculate a new forward vector every frame, don't re-use it and apply new rotations to the forward vector since small errors, that eventually become large errors, will creep in.