Move player towards screen

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By overcrookd

I’ve got a fixed projection perspective camera with a vertical FOV of 70 deg and rotated 45deg on Y axis.

Player movement is along Camera’s X axis (right/left), Z axis (front/back), Y axis is set to 0.

What I’d like to achieve is for the player to move directly towards the screen top/bottom when pressing forward/back keys instead of moving along camera’s Z axis which causes and illusion of traveling at an angle the further from the center of the screen you are (which makes sense but is not desired in this case).

The screenshot below depicts:

  • Green: Direction to camera
  • Blue: Camera’s Z axis (player movement forward/back)
  • Red: Desired forward/back movement vector

I was able to brute-force some values like if camera’s Z axis are at 45deg to the player-camera direction then the desired rotation would be half of that (22.5deg) but I can’t seem to find a solution for the rest of the world positions due to my lack of Math knowledge.