Help with player radar system

My code is shoddy and math is bad. Help me make a player orientated radar work.

I’d like the radar to be centered on the player but also using the character’s rotation as a reference to orientate the radar. Something similar to the Phantom Forces radar.

So far I have:

for i,lifeform in pairs(players:GetChildren()) do
		if lifeform.Character and lifeform.Character.HumanoidRootPart then
			if (lifeform.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude < 50 then
				--/ Player detectable
				
				local scaleFactor = 1/100
				
				local myHumanPos = player.Character.HumanoidRootPart.Position
				local detectHumanPos = lifeform.Character.HumanoidRootPart.Position
				
				local offset = (detectHumanPos - myHumanPos)
				local relOffset = math.atan2(offset.y,offset.x)
				
				local magnitude = offset.Magnitude
				
				local finalOffset = Vector2.new(math.cos(relOffset) * magnitude, math.sin(relOffset) * magnitude) * scaleFactor
				
				local blipClone = blip:Clone()
				blipClone.Parent = scannerGui
				blipClone.Name = lifeform.Name
				
				blipClone.Position = UDim2.new(finalOffset.X + 0.5, 0, finalOffset.Y + 0.5, 0)
				
				spawn(function()
					wait(2)
					blipClone:Destroy()
				end)
				
			end
		end
	end

What my UI looks like for it:

image

Green dot being the client.
Red ‘blips’ being other players, around the green dot.

So far, the ‘blip’ is moving on the X axis, none on the Y and is not using the player as a reference orientation.

Any help is appreciated!

2 Likes

I think you are looking for the Z property of Vector3 instead of Y.

I’m using Vector2, but I tried with Vector3 and Z axis but no luck; same results.

image

I believe you are looking for the player’s “heading.” The heading is the term used to describe an object’s direction in the XZ plane. Think of an airplane flying in the sky, if its heading northeast, then it’s traveling in the direction up and to the right in the XZ plane (assuming a relatively flat plane).

to get the heading of the player’s HumanoidRootPart, use this:

local heading = math.atan2(HumanoidRootPart.CFrame.RightVector.Z, HumanoidRootPart.CFrame.LookVector.Z)
2 Likes

I managed to scrape up something using the rotation property of the heading. I used Vector2’s to position the elements. So basically, add a secondary frame parented to the main map. This should be invisible as it is going to rotate with the player.

[https://gyazo.com/92365fdf93d3215421fb1901a2258881]

Here is the file for my version, feel free to modify how you want. Minimap.rbxl (29.0 KB)

1 Like

You’re amazing, thank you so much!

1 Like