so how would i make this npc follow a straighter path since i wanna make a guard patrol system.
wait(5)
local PFS = game:GetService("PathfindingService")
local npc = script.Parent
local humanoid = npc:WaitForChild("Humanoid")
local goalPart = game.Workspace.PathfindingTEst
local path = PFS:CreatePath()
local success, errorMessage = pcall(function()
path:ComputeAsync(npc.PrimaryPart.Position, goalPart.Position)
end)
if success then
for _,waypoint in pairs(path:GetWaypoints()) do
local part = Instance.new("Part")
part.Material = "Neon"
part.Anchored = true
part.CanCollide = false
part.Shape = "Ball"
part.Position = waypoint.Position
part.Parent = game.Workspace
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
else
warn(errorMessage)
end
Try increasing the AgentRadius parameter when creating path
wait(5)
local PFS = game:GetService("PathfindingService")
local npc = script.Parent
local humanoid = npc:WaitForChild("Humanoid")
local goalPart = game.Workspace.PathfindingTEst
local path = PFS:CreatePath({
AgentRadius = 4,--Adjust based on space
AgentHeight = 6
})
local success, errorMessage = pcall(function()
path:ComputeAsync(npc.PrimaryPart.Position, goalPart.Position)
end)
if success then
for _,waypoint in pairs(path:GetWaypoints()) do
local part = Instance.new("Part")
part.Material = "Neon"
part.Anchored = true
part.CanCollide = false
part.Shape = "Ball"
part.Position = waypoint.Position
part.Parent = game.Workspace
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
else
warn(errorMessage)
end