How would you determine the direction of a position when compared to the character?

The Problem
I have been struggling to solve this problem as my understanding of math is lacking. In my game I have a map and a player can place a pin on it so he can go to that pin easier. One way I want to make that is easier is to add a pin to the compass bar.
image
As you can see there’s a pin point on the map and a compass telling the player which way their camera is facing. How would I be able to add a pin onto this compass bar accurately pointing towards the pin. Help will gratefully accepted.

1 Like

Seems like a cool system to try to develop!

Im not good with CFrame, but should be a method for compare the HumanoidRootPart orientation/angles vs the world coordinates of a spot. That angle difference number could be translated to a number between 0 - 1, and then move the pin point along the size of the compass GUI based on that number. Or attach the pin point to a scaled position inside the compass GUI so it moves along with the compass. Depends how you are “spining” your compass GUI

What math you did to make the compass “spin” when the player turns, to move it exactly to the coordinate the player is facing?

1 Like

Get a 2d position with camera:WorldToViewportPoint() and position the locator gui to an x coordinate clamped to the compass gui’s absoluteposition +/- absolutesize, and same with the y value. if the x exceeds left or right limits then don’t show it. And you should update it every frame in a renderstepped loop.

1 Like