Hey,
after days of not finding a solution in a thread I made in Roblox, I've decided to come here for help. The problem is that the path created by :ComputeSmoothPathAsync
's status is always ClosestNoPath, and only if the enemy gets really close (<1 studs) will the npc move slightly towards it. I also found out that the table returned from :GetPointCoordinates()
is only 1, which is why my NPC won't move. Here is the code:
while wait(0.2) do local enemy = getnearestenemy() if enemy then local compute = pathfinding:ComputeSmoothPathAsync(script.Parent.Parent.Torso.Position,enemy.Torso.Position,512) local point = compute:GetPointCoordinates() print(#point) if #point > 2 then script.Parent:MoveTo(point[3]) end end end
The variable "enemy" is simply the nearest enemy to the NPC, and pathfinding is game:GetService("PathfindingService")
.
I have tried setting the EmptyCutoff to a much lower, and higher value but that doesn't work. Switching to RawPath instead of SmoothPath apparently doesn't work either. I also googled the problem online, to no avail. How would I fix this problem so that my NPC moves to the nearest enemy properly?
EDIT: to view the code without that cutoff just copy to clipboard, and paste into something like notepad.