I basically took one of the starting templates and attempted to modify it to have a constantly pathfinding NPC.
Why does this constantly return no waypoints?
There are no errors in console.
local PathfindingService = game:GetService("PathfindingService")
local PATROL_DELAY = 1
local enemy = script.Parent
local humanoid = enemy.Humanoid
local humanoidRootPart = enemy.HumanoidRootPart
while wait(PATROL_DELAY) do
local currentDestination = workspace.hallowCore
-- Make variables for the start and end of the path
local startingPosition = humanoidRootPart.Position
local goalPosition = currentDestination.Position
-- Find a path to the enemy's current destination
local path = PathfindingService:FindPathAsync(startingPosition, goalPosition)
local waypoints = path:GetWaypoints()
-- Loop through all of the waypoints in the path
for waypointIndex, waypoint in pairs(waypoints) do
print(waypoint.Position)
local part = Instance.new("Part")
part.Position = waypoint.Position
part.Size = Vector3.new(1, 1, 1)
part.Anchored = true
part.Parent = game.Workspace
local waypointPosition = waypoint.Position
-- Make the humanoid move to the current waypoint
humanoid:MoveTo(waypointPosition)
-- Wait until the humanoid has reached its target
humanoid.MoveToFinished:Wait()
end
end
So despite the navmesh being valid, the pathfinder couldn’t seem to find a valid path through the viable navmesh. I solved it by placing a dud brick for it to seek instead of the actual target.
ClosestOutOfRange is deprecated. FindPathAsync() does not limit the range of the path.
Not sure if this is your case, but path requests could fail if either start and/or end locations are too far from the navmesh.
If you have a repro place I could investigate this further.
I think the issue was that I wanted the NPC to pathfind to a large ball’s position, which isn’t exactly possible cause the center is unreachable (if that makes sense).
Ah, path finding, my favorite topic! Where are the start and goal positions being set to relative to the ground and nearby objects when you don’t use a proxy part? I’ve gotten this error when the points are too high or too close to a Mesh with a weird invisible collision mesh.
It could potentially be that the target part of the pathfinding was considered to be an obstacle so the path was returning invalid – although that means that the returned Enum might be different. Oh well. Pleased that you found a solution anyway
Ah yes, both the height and sphere were probably issues. I probably should have read a bit more carefully, as I see you already mentioned that as a possibility. I’m a simple man: I see a pathfinding topic, and I post! Even if it is already solved…