I have a position somewhere on my map (in GTAV). In JavaScript it could be something like:let targetPos = {x: 1200, y: 653, z: 250};
and I have my position which changes every time I walk or rotate. Now what I want is to get the direction of the targetPos whenever I rotate or walk. Not the function but the math solution. Currently I'm using var angle = Math.atan2(pos1.y - pos2.y, pos1.x - pos2.x) * (180 / Math.PI);
which is not working as intended. It gives me the angle in degree but not when I rotate myself or when I walk around it. In short: I want the direction of a position relative to my position. So I can rotate a circle to show in the target direction.
Here is what I have:
- The player position (x, y, z), rotation (x, y, z) and heading (yaw)
- The target position
As you can see in the horrible image, the circle doesn't show in the direction of the target when the player rotates
I hope you know what I mean