Overlay ImageLabel with Part on SurfaceGui from player's perspective

  1. What do you want to achieve? I want to have an ImageLabel on a SurfaceGui display over a part in the workspace from the player camera’s perspective.

  2. What is the issue? I cannot think of a way to achieve this effect, as it might require complex calculations I am just incapable of scripting in.

  3. What solutions have you tried so far? I have tried using ViewportFrames as well as camera:WorldToScreenPoint(part.Position), none of which produce expected results. My previous post on this matter has been quite complicated and has therefore received no replies, for which I apologize. I have been trying to crack this issue for almost a week now and I’m very desperate for results.

It’s imperative to note that the SurfaceGui behaves like a collimator (it’s contents are projected an infinite amount of distance away). This is how I achieve the effect:

		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)
		end

Here is a video of how it behaves as of right now.

Here is a video from DCS World, a military flight simulator. At around the 0:16 mark is the effect I want to achieve, a circle highlighting the currently selected 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.