Translation Based On Previous Rotation

I’m getting started on my game, and I’m stuck on a math problem. The setup is this:

  • I control a character model in 3rd person.
  • I can rotate the character model counter-clockwise and clockwise using A and D keys.
  • I can translate the character model forward and backward using W and S keys.

    The problem is this:

    Translating isn’t relative to my rotation. So if I’m facing North and press W (forward) I move North. If I rotate to face East and press W I move North, not East. I need to press W and move in the direction I am facing. My difficulty is that I don’t know what type of operation I need to pursue - all tutorials and books I’ve looked through so far explain translation and rotation separately from each other, rather than building off each other. Definitely no “this is how you translate in the direction based off your current rotation”. (Just fyi, I’ve taken up through Calculus 2, no Diff Eq.)

    So, if anyone can enlighten me, either through a direct explanation, link to something that explains this, or even just naming what kind of operation I need to use to help me research this myself, I’d greatly appreciate it!



This might help:

Your direction is a vector. Your position is a vector. pos + direction = new position.

Or just look and see what FlyByCamera does.