-
What do you want to achieve? I want to achieve a consistent overlay of an ImageLabel with a part in the workspace, regardless of where the player’s head is, where they are looking, or what their field of view is. It’s imperative to note that the SurfaceGui behaves like a collimator, meaning it has optical infinity and whatever is inside it is projected an infinite amount of distance away. That means whatever is projected stays in the same place regardless of viewing angle, unlike a normal SurfaceGui which would behave like a screen.
-
What is the issue? I am unable to think of a solution to this problem, something like camera:WorldToScreenPoint(part.Position) does not produce expected results.
-
What solutions have you tried so far? I tried using camera:WorldToScreenPoint(part.Position), with unsatisfactory results. I cannot think of any different solution. I’d appreciate help from anyone who had to deal with a similar issue.
I am simply requesting ideas for a possible solution.
My ultimate goal is to have a circle that overlays with a part in the workspace, and is clipped by another “window” part to fit inside the head-up display’s frame.
This is the logic I use to simulate optical infinity.
local screen_size = HUD.PixelsPerStud
if (workspace.CurrentCamera.CFrame.p - HUD.Parent.Position).Magnitude < 6 then
camera.offset = HUD.Parent.CFrame:PointToObjectSpace(workspace.CurrentCamera.CFrame.Position)
base.Scale.Scale = camera.offset.Z / camera.max * 0.8
base.Position = UDim2.new(0.5, camera.offset.X * screen_size, 0.5, -camera.offset.Y * screen_size)
Thank you to anyone who decides to help out!