I’m making a radar for a game and I’ve done all the basic things but I’m not good at math and don’t know how to show a players LookVector on the radar. I basically just want a line extending 10-20 studs from the middle of the playerdot in the direction they are looking at.
local DeltaPos = Camera.CFrame:PointToObjectSpace(RootPart.Position)
local DotPos = Vector2.new(DeltaPos.X + RADAR_SIZE / 2 + RADAR_PADDING, DeltaPos.Z + RADAR_SIZE / 2 + RADAR_PADDING)
local LookVector = RootPart.CFrame.LookVector
local X = math.clamp(DotPos.X, RADAR_PADDING, RADAR_SIZE + RADAR_PADDING) * RADAR_SCALE
local Y = math.clamp(DotPos.Y, RADAR_PADDING, RADAR_SIZE + RADAR_PADDING) * RADAR_SCALE
To create the player dot position all I do is UDim2.new(0, DotPos.X, 0, DotPos.Y)
In the same way you used CFrame:PointToObjectSpace(Vector3),
you can use CFrame:VectorToObjectSpace(Vector3) and disregard the Z component.
local RelativeLookVector = Camera.CFrame:VectorToObjectSpace(RootPart.CFrame.LookVector)
local DirectionOnMap =Vector2.new(RelativeLookVector.Y, RelativeLookVector.X))