Path Finding issue, its moving WEIRD

i realy dont know why its moving so weird.

here is the scourcecode

wait(1)
local char = script.Parent
local primarypart = char.PrimaryPart
local humanoid = char.Humanoid
primarypart:SetNetworkOwner(nil)
local pathpoints = workspace.Pathpoints
for pathpoint = 1, #pathpoints:GetChildren() do

	local goal = pathpoints[pathpoint]
	local pfs = game:GetService("PathfindingService")
	local path = pfs:CreatePath(
		{
			AgentRadius = 0,
			AgentHeight = char:GetExtentsSize().Y,
			AgentCanJump = true,
			Costs = {
				CrackedLava = math.huge,
				Path = 1, 
				Plastic = 1
			},
			WaypointSpacing = math.huge
		}
	)
	local success, errormessage = pcall(function()
		path:ComputeAsync(primarypart.Position, goal.Position)
	end)
	if success and path.Status == Enum.PathStatus.Success then
		local waypoints = path:GetWaypoints()
		for i, v in pairs (waypoints) do
			print(i)
			humanoid:MoveTo(v.Position) 
			humanoid.MoveToFinished:Wait()
		end
	elseif success and path.Status == Enum.PathStatus.NoPath then
		warn("no Path ", errormessage)
	elseif not success then
		warn("no Compute ", errormessage)
	end
end
error("NPC Finished Course")

I had a similar problem before with something like this and I found this tutorial and it helped me a lot.

2 Likes

This is trash, i want to use the Pathfinding system and not the SIMPLE Humanoid MoveTo function…
Not only do I want them to go BORING straight, I want them to go around curves, that is, in an arc, and not move towards the point and then just turn like that.

You are also using MoveTo?


Instead of doing humanoid.MoveToFinished:Wait() you should continuously check whether the npc is close enough to the current point, if so then go to the next point.

That way the npc won’t overshoot the checkpoints like in your video.


Doing humanoid.MoveToFinished:Wait() works in BrokenV0id’s video because the npc is moving very slowly.

It looks like the humanoid is moving too fast, and thus overshooting the corners.

Does this issue occur while moving slower?

still straight i want to them to go in curves and not STRAIGHT

then they are just going straight

You’ll probably need to detect corners somehow and rebuild the path waypoints to curve rather than be a 90 degree turn then.

What if you pathfind from start to finish, instead of to every corner?

Then it should take sharper corners.


Also you could look into splines to make the path smoother, though I’m not sure whether the npc will stay on the road if you do that.

Here is a Roblox module for cubic hermite splines

he is TWEENING and not MoveTo Using. i want to NPC’s to Walk and not to Slide.

??? who is tweening?


Also, did you try

what did you just send? HE IS NOT EVEN USING AN HUMANOID… HE IS MOVING PARTS AND NOT AN NPC.

its moving weird since u make the whole humanoid massless, disable massless to make it less slippery

It’s an example.

It’s a module for generating points from fewer points. You can use those points however you like, whether it be tweening or moving a humanoid with MoveTo…


ALSO

still not for Humanoid moveto, its for PARTS.

It’s for generating a cubic hermite spline using the Catmull–Rom algorithm.

wikipedia

aha and how is that even usable for me?

Because it turns this


into this


You want the npc to go in a curve right?

yes i want them to walk Realistic and not just like robots…

Then the module I linked to is exactly what you need.