You can write your topic however you want, but you need to answer these questions:
I want to achieve a simple pathfinding system for an npc
It only walks into walls and jumps when your in a higher plane
I’ve searched Far but I haven’t been able to find a good solution
local function CreatePath(Part, Chaser)
Chaser.HumanoidRootPart:SetNetworkOwner(nil)
local success, errorMessage = pcall(function()
Path:ComputeAsync(Chaser.PrimaryPart.Position, Part.PrimaryPart.Position)
end)
return Path
end
local function MoveToPart(Part, Chaser)
local Path = CreatePath(Part, Chaser)
if Path.Status == Enum.PathStatus.Success then
for _, waypoint in pairs(Path:GetWaypoints()) do
Chaser.Humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
Chaser.Humanoid.Jump = true
end
end
end
end
it uses a while task.wait() loop for it, I know it isn’t the best but I have found no solutions for this
I struggle to explain it sorry, but It moves a set of waypoints and waits until its completed moving to all of those waypoints ( the movetofinished ) before updating the path