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:
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!