in the video, the pathfinding updates every time i move.
the issue is that it stutters in the beginning of the recreation of the path when updating
here’s the code
while true do
if Pathfinding.Paths[Selection] ~= Goal then
coroutine.yield()
else
local Current = NewestCFrame
local Path = PathfindingService:CreatePath()
Path:ComputeAsync(Selection.HumanoidRootPart.Position, NewestCFrame.Position)
for Iteration, Waypoint in pairs(Path:GetWaypoints()) do
NewestCFrame = Goal.CFrame * Offset
if Current ~= NewestCFrame then
break
end
Selection.Humanoid:MoveTo(Waypoint.Position)
if Waypoint.Action == Enum.PathWaypointAction.Jump then
local Moving = true
Selection.Humanoid.MoveToFinished:Connect(function()
Moving = nil
end)
repeat Selection.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping) task.wait(0.1) until not Moving
else
Selection.Humanoid.MoveToFinished:Wait()
end
end
if Current == NewestCFrame then
Selection.Humanoid:MoveTo(NewestCFrame.Position)
end
end
end