So, I’ve been trying to implement the features of waypoints by using a compass UI that will N,E,S, & W, along with the waypoints. I managed to make it where the N,E,S, & W labels work but I haven’t been able to find a solution to getting a waypoint to point where the waypoint is at. I also want it to constantly point at where the waypoint is at when the player’s position moves.
Here is the script for the compass UI.
local smoothness = 30/3
wait(1)
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local dev = script.Parent
local lastY = 0
local units = {
[dev.N ] = -math.pi * 4/4;
[dev.NE] = -math.pi * 3/4;
[dev.E ] = -math.pi * 2/4;
[dev.SE] = -math.pi * 1/4;
[dev.S ] = math.pi * 0/4;
[dev.SW] = math.pi * 1/4;
[dev.W ] = math.pi * 2/4;
[dev.NW] = math.pi * 3/4;
[dev.Frame] = math.pi * game.Workspace.Furnace.PromptPart.Position.X/game.Workspace.Furnace.PromptPart.Position.Y;
}
local Waypoints = {
[dev.Frame] = math.pi * game.Workspace.Furnace.PromptPart.Position.X/game.Workspace.Furnace.PromptPart.Position.Y;
}
function restrictAngle(angle)
if angle < -math.pi then
return angle + math.pi*2
elseif angle > math.pi then
return angle - math.pi*2
else
return angle
end
end
while true do
local delta = wait(1/30)
local look = camera.CoordinateFrame.lookVector
local look = Vector3.new(look.x, 0, look.z).Unit
local lookY = math.atan2(look.z, look.x)
local difY = restrictAngle(lookY - lastY)
lookY = restrictAngle(lastY + difY*delta*smoothness)
lastY = lookY
for unit, rot in pairs(units) do
rot = restrictAngle(lookY - rot)
if math.sin(rot) > 0 then
local cosRot = math.cos(rot)
local cosRot2 = cosRot*cosRot
unit.Visible = true
unit.Position = UDim2.new(0.5 + cosRot*0.6, unit.Position.X.Offset, 0.5, 0)
else
unit.Visible = false
end
end
end
Here’s the where the script is located.
If needed I will elaborate further on what I want to try to achieve. Any help will be appreciated!