As you can see in the image above the NPC moves to 1-2-3-4 correctly but at 5th he stops before reaching the end and continue the loop normally
while 1 do
for i,v in PathNodes do
if Animation ~= nil then Animation:Stop() end
Animation = Humanoid:LoadAnimation(SetSpeedAndGetAnimation(v["WalkFromHere"].Value))
Animation:Play()
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait()
Animation:Stop()
Animation = Humanoid:LoadAnimation(IdleAnimation)
Animation:Play()
task.wait(v["WaitTime"].Value)
end
end
PathNodes are those red parts in the Image above
that SetSpeedAndGetAnimation() is where I set the humanoid speed and returns the correct animation.
Is there any limitations to the MoveTo() function?
how can I fix this? any help would be appreciated
The documentation used to say that if your NPC has not reached its MoveToFinished within that 8 seconds, to call another MoveTo function on the NPC and this will reset the 8 seconds… ofcourse a hacky method is to add an invisible waypoint between 4 and 5 to circumvent this.
You can check for the NPC reaching its MoveToFinished, and if it hasn’t then you call another MoveTo yes… its always been a pathfinding issue, and the easiest method is just to create invisible waypoints that are close together so that this 8 second limit isn’t reached. This is why i’ve always struggled with pathfinding, it’s too bad you can’t adjust the time restriction (not that i know of atleast).
Check the path nodes to make sure they are in clear, accessible areas.
Try adjusting the position of the destination point slightly to see if that helps.
Increase the WalkSpeed of the humanoid to get to the destination faster.
You can also try using the PathfindingService and Path class to generate a more accurate path to the destination. This would involve creating a Path object between the NPC’s current position and the destination, and then using the MoveToPart() function to move the humanoid along the path
1.They Are
2.If they are closer, they works perfectly
3.want to them to be able to walk/run so different speeds
4.I have no experience with “PathfindingService” but i can research it bit wont MoveToPart() Have the same exact 8 second limitatiion?
function MoveNPC(v)
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:Wait()
local Distance = (RootPart.Position - v.Position).Magnitude
if(Distance < 2) then
return
else
return MoveNPC(v)
end
end
while 1 do
for i,v in PathNodes do
if Animation ~= nil then Animation:Stop() end
Animation = Humanoid:LoadAnimation(SetSpeedAndGetAnimation(v["WalkFromHere"].Value))
Animation:Play()
MoveNPC(v)
Animation:Stop()
Animation = Humanoid:LoadAnimation(IdleAnimation)
Animation:Play()
task.wait(v["WaitTime"].Value)
end
end
all I’m checking is the distance between player and node once the move finished/failed