How to make nodes/waypoints


i want to make nodes for my phone map, but i literally don’t know anything on how to make it

(i figured i needed to like translate the red part’s position to a ‘ui’ position and make a frame representing the part as a waypoint but still don’t know how)

so please help! thanks in advance

2 Likes

Vector3, Vector2 stuff all use integers, so you can just only use the x and z coordinates of the part and leave out the y

local part = workspace.Part
local UIPos = Vector2.new(part.Position.X, part.Position.Z)
print(UIPos)
1 Like

OP needs the point to appear on the phone, so you would also need some scaling, if I’m not mistaken?

image

2 Likes

would PathfindingService fit your need in this case?
also, here is a sample if you wish to see for example;

local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath({
    AgentRadius = 3,
    AgentHeight = 6,
    AgentCanJump = false,
    Costs = {
        Water = 20
    }
})

local startPosition = Vector3.new(10, 10, 10)
local finishPosition = Vector3.new(20, 20, 20)

local success, errorMessage = pcall(function()
    path:ComputeAsync(startPosition, finishPosition)
end)

if success and path.Status == Enum.PathStatus.Success then
    local waypoints = path:GetWaypoints()
    for _, waypoint in ipairs(waypoints) do
        -- Create a node at the waypoint position
        local node = Instance.new("Part")
        node.Position = waypoint.Position
        node.Size = Vector3.new(0.5, 0.5, 0.5)
        node.Anchored = true
        node.CanCollide = false
        node.Parent = game.Workspace
    end
end

Note: I am by no means, a expert in scripting, but please let me know if the pathfindingservice engine will help fit your need.

3 Likes

what do you think a Vector is made of?

1 Like

Floating-point numbers?

1 Like

Math OR Numbers

2 = 2 * 1
1 * 1.5 = 1.5

Vectors can be comprised of non floats or non integers

Technically 1 = 1.0000000000000 but if it isnt a float it isnt a float

1 Like

You get what I mean anyway though. The guy didn’t say

either, he just said that they all use integers, so…

2 Likes

I know, but you said they all use floats :thinking:

1 Like

sorry for the lack of information, but what i want to do is, have a part in 3d workspace called “node” and have it show up in the phone map…

(with node/waypoint, i dont mean the variables in pathfinding)

and i don’t think what you mean is that (correct me if im wrong)

but still, thanks for your help tho!

i will check this out and, give you the results.

i think technically it could work. But, i use a chunk based map and i tried normalizing the UIPos w/ the minimap, and it didn’t work as i intended it to do.

here’s my phone map script:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
local RS = game:GetService("ReplicatedStorage")

local camera = workspace.CurrentCamera
local Phone = script.Parent.Parent.Parent.Parent
local Screen = Phone.Main.Screen
local delAppFrame = Screen.DeliveryApp
local delAppVPFrame = delAppFrame.ViewportFrame
local playerIndicatorTemplate = delAppFrame.Player
local deliveryIcon = Screen.DeliveryIcon
local exitButton = Screen.ExitButton
local openDeliveries = Screen.OpenDeliveries
local DeliveriesDB = delAppFrame.DeliveriesDB

local open = false

local waypoint = workspace:WaitForChild("Waypoint")

-- Remove the template from the frame
playerIndicatorTemplate.Parent = nil

-- Minimap variables
local offset, chunkSize, chunkHalfSize, currentX, currentZ
local scrollSpeed = 500
local playerIndicators = {}

-- Minimap Camera
local viewportCamera = Instance.new("Camera")
viewportCamera.FieldOfView = 20
delAppVPFrame.CurrentCamera = viewportCamera

-- Clone the map into the viewport frame
for _, descendant in ipairs(workspace.Map:GetDescendants()) do
	if descendant:IsA("BasePart") then
		descendant:Clone().Parent = delAppVPFrame
	end
end

-- Update minimap position and viewport camera
local function UpdateMinimap()
	local focusX = camera.Focus.Position.X / chunkSize
	local focusZ = camera.Focus.Position.Z / chunkSize
	local chunkX, chunkZ = math.floor(focusX), math.floor(focusZ)
	local x, z = focusX % 1, focusZ % 1

	if currentX ~= chunkX or currentZ ~= chunkZ then
		currentX, currentZ = chunkX, chunkZ
		local position = Vector3.new(chunkX * chunkSize + chunkHalfSize, 0, chunkZ * chunkSize + chunkHalfSize)
		viewportCamera.CFrame = CFrame.lookAt(position + offset, position, -Vector3.zAxis)
	end

	delAppVPFrame.Position = UDim2.new(1 - x, 0, 1 - z, 0)
end

-- Update player positions on the minimap
local function UpdatePlayers()
	local focusX = camera.Focus.Position.X / chunkSize
	local focusZ = camera.Focus.Position.Z / chunkSize

	for player, gui in pairs(playerIndicators) do
		if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			local cFrame = player.Character:GetPivot()
			local x, z = cFrame.Position.X / chunkSize, cFrame.Position.Z / chunkSize
			gui.Position = UDim2.new(0.5 - focusX + x, 0, 0.5 - focusZ + z, 0)
			gui.Rotation = -player.Character.HumanoidRootPart.Orientation.Y
		end
	end
end

--[[ NOT IMPORTANT
-- Player joins: Add to minimap
local function PlayerAdded(player)
	local gui = playerIndicatorTemplate:Clone()
	gui.PlayerName.Text = player.Name
	gui.Parent = delAppFrame
	playerIndicators[player] = gui
end

-- Player leaves: Remove from minimap
local function PlayerRemoving(player)
	if playerIndicators[player] then
		playerIndicators[player]:Destroy()
		playerIndicators[player] = nil
	end
end


-- Set minimap zoom level
local function SetMinimapZoom(value)
	offset = Vector3.new(0, value, 0)
	chunkSize = offset.Y * math.tan(math.rad(viewportCamera.FieldOfView) / 2)
	chunkHalfSize = chunkSize / 2
	currentX, currentZ = math.huge, math.huge
	UpdateMinimap()
end

RunService.RenderStepped:Connect(function()
	UpdatePlayers()
end)

SetMinimapZoom(500)

--]]
camera:GetPropertyChangedSignal("Focus"):Connect(UpdateMinimap)

--normalizing
local UIPos = Vector2.new(waypoint.Position.X/chunkSize, waypoint.Position.Z/chunkSize)

--what i tried
local frame = Instance.new("Frame")
frame.Parent = delAppVPFrame
frame.Size = UDim2.new(0.1, 0, 0.1, 0)
frame.BackgroundColor3 = Color3.new(1, 1, 1)
frame.Position = UDim2.fromOffset(UIPos.X, UIPos.Y)

--[[
-- UI button interactions
deliveryIcon.MouseButton1Click:Connect(function()
	delAppFrame.Visible = true
	exitButton.Visible = true
	openDeliveries.Visible = true
end)

exitButton.MouseButton1Click:Connect(function()
	delAppFrame.Visible = false
	exitButton.Visible = false
	openDeliveries.Visible = false
end)

openDeliveries.MouseButton1Click:Connect(function()
	DeliveriesDB.Visible = not open
	open = not open
end)

-- Scroll zoom functionality
UIS.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel and Screen:IsAncestorOf(delAppFrame) then
		SetMinimapZoom(offset.Y + (-input.Position.Z * scrollSpeed * 0.05))
	end
end)

-- Disable scrolling when inside the app
CAS:BindAction("DisableScroll", function()
	return Screen:IsAncestorOf(delAppFrame) and Enum.ContextActionResult.Sink or Enum.ContextActionResult.Pass
end, false, Enum.UserInputType.MouseWheel)

-- Connect player events
for _, player in pairs(Players:GetPlayers()) do PlayerAdded(player) end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerRemoving)
--]]

fyi, i followed suphi Kaner’s tutorial on making a minimap
Minimap - Roblox Scripting Tutorial - YouTube

1 Like