Targeting collimator with SurfaceGui

  1. 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.

  2. 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.

  3. 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!

Didnt understand too much, could you provide a example?

Ofcourse! This is a clip of the HUD I have right now. It behaves like a normal HUD would. Below there is a screen with a copy of the HUD, the HDD. As you can see, it moves and has a finite focus.

What I am trying to achieve is to have a circle overlaid with a part which is considered my target. A good example of what I’m trying to achieve is a HUD from DCS. (Around the 20 second mark, there is a circle clearly overlaid with the target.)

Figured it out myself. Closing the discussion, or lack thereof I guess.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.