Hello,
I’m currently experimenting with the basics of pathfinding, and I’m trying to add a feature where the pathing adapts to any updates on the map and changes the path accordingly, but I’m not sure how. If anyone is able to help that’d be great. Here’s my code:
local humanoidpart = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("UpperTorso")
ending = game.Workspace.End
local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.Position, ending.Position)
local waypoints = path:GetWaypoints()
if path.Status == Enum.PathStatus.NoPath then
print("no path found")
else
print("path found")
end
for i, v in pairs(waypoints) do
if v.Action == Enum.PathWaypointAction.Jump then
humanoidpart:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoidpart:MoveTo(v.Position)
humanoidpart.MoveToFinished:Wait(1)
end
humanoidpart:MoveTo(ending.Position)