This question is related to my other question about camera rotation. I hope its acceptable to ask a second question. I cannot figure out the math of how to calculate moving the camera to stay behind my player, based on the players rotation.
In the image above, the arrow represents a player with the direction of the arrow representing the direction the player is facing. The red object represents camera. I want the camera to always remain behind the player. When the player turns, I want the camera to move behind the player. I cannot figure out the math for calculating where to move to.
Step 1 The arrow is at 0,0 and facing 0 (north). The red circle is at 0,-5
Step 2 the arrow is at 0,0 and turned 90 degrees to the right (facing east). The red circle should move to be "behind the arrow" aka to the left and up and at the same distance from the arrow as when it started. I am guessing that would be -5,0 in this case
Other Scenarios a) The arrow is at 0,0 and turned -30 degrees (turned to the left). The red circle should move right and up.
b) the arrow is at 0,0 facing south (180 degrees opposite of #1) and turns -30 degrees to right (on screen but left if you are the arrow). The red circle should move appropriately.
I have racked my brain over this for days and just cannot find an answer. Thnx Matt