What way are you storing your player’s orientation / viewing direction ?
If you’re using just a single angle for direction (no looking up or down – like Doom) then you can get the direction like this:
direction_x = – sin(playerAngle)
direction_y = 0
direction_z = – cos(playerAngle)
.. The above assumes at angle zero your player faces into the screen and that rotation is clockwise for the player. You may have to change the signs around a bit though depending on how your coordinate system or camera etc. is set up.
If you want looking up and down (pitch rotation) as well turning around (yaw rotation) then you will have to modify the equations as follows:
direction_x = – sin(playerYawAngle) * cos(playerPitchAngle)
direction_y = – sin(playerPitchAngle)
direction_z = – cos(playerYawAngle) * cos(playerPitchAngle)
.. This lot has the player’s head level at pitch angle = 0 and an increase in the angle will tilt the players head down towards the ground. Again you may have to tweak the signs if it doesn’t work in your app.