Hi!
I’m trying to make a GUI arrow image that points toward a specific part. This is done by converting the 3D position of the part into 2D using WorldToScreenPoint.
The issue is that when looking certain directions (refer to image & video below) the arrow points in the opposite direction that it’s supposed to. This is further confirmed by some debugging I did. From what I’ve gathered, the on screen position of the part seems to be randomly going from around 500K to around -26K suddenly.
This is the code I use to rotate the image. (Called every RenderStepped)
local pointOnScreen = workspace.CurrentCamera:WorldToScreenPoint(target.Position)
local absPos = GUI.Frame.AbsolutePosition + Vector2.new(GUI.Frame.AbsoluteSize.X / 2, GUI.Frame.AbsoluteSize.Y / 2)
local angle = math.deg(math.atan2(pointOnScreen.Y - absPos.Y, pointOnScreen.X - absPos.X))
GUI.Frame.Rotation = angle
Edit: The video above shows the arrow snapping to a position opposite of the target position.