I cannot figure out how to calculate coordinates based on the degrees of rotation of another object.
I hope this is right forum to ask this question. I am trying to write code for my game that will keep one object behind another.
In the image above, the arrow represents a player. I want the red circle to always remain behind the player. When the player turns, I want to the red circle (aka move to new position) behind the arrow. 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 do not know this math. I do not what to do. If I may ask, please keep this algebraic as I do not know calculus.
Thnx Matt
