(Legacy) SimplePath - Pathfinding Module

Stuttering consists and seems to have gotten a bit more noticable. Same effect happens with NCD but more intense. https://gyazo.com/c053496044ce900c30861df455f45a3d

For it to be more understandable when it happens:
When the part is moved, another path is created.
While its being created, the NPC stops to compute the path which lasts for a few miliseconds
if the part is moved a lot, the NPC will keep stopping for few miliseconds to recompute the newly generated path.

if there’s any sort of delay when creating and computing the path, try removing it or changing it to be a lot more faster. To replicate this issue, move the goal a lot with your mouse really fast.

Edit: The problem below is fixed.

Unfortunately, that’s how long it takes PathfindingService to compute a new path. If I try to remove or reduce the wait time somehow, it ends up overlapping with other parts of the script and overshoots the waypoints (the same issue you first noticed) and ends up colliding with obstacles instead of going around it. The maximum you can do is disable path visualization and only notice the ever so slight stutter:

2 Likes

alright. Do you have any solutions to a way to reduce the high intense stutter of the SDC to the same/similar results as the non custom rig like in the video?

If you’re talking about the example in the post above, thats directly from the module using the script mentioned in the example.

So i guess SDC is stuttering more intensely than the example because of the rig?

1 Like

Yes that stuttering is all that I can do for now. I’ll continue to make changes to the script and hopefully find a solution in the future. I’m not entirely worried about this since the main purpose of Run() is not to continuously create a seamless path for the humanoid. Rather, it was created to make it easier for people so they dont have to worry about stopping the path before creating a new one.

Anyway, I’m glad you caught that fatal bug and I hope my module will be of use in your projects. :grin:

2 Likes

Update 0.22:

  • SimplePath.new() saves the Path object at default. This can now be disabled (see api). Disabling this feature maximizes the performance but the Path object specific to the rig will not be retrievable (if the Path object was saved, it is automatically retrieved if you run Path.new() on the same rig).
  • Minor bug fixes.
3 Likes

Update 0.23:

  • Fixed a bug involving NetworkOwnership.
2 Likes

coolio!

by the way, i have a suggestion:
maybe you should add an option that when enabled, makes the pathfinding NPC try their best to go to a player/humanoid npc and have the humanoid be customizable, because it is kinda difficult to have it chase NPCs due to the fact that i have to manually edit the code and it only chases npcs to their last position and it’d be quite helpful if this was added

great module though! keep up the good work

1 Like

Thanks for the feedback. I will definitely consider adding that feature soon.

Update 0.24:

  • MAJOR FIX: Spamming Path:Run() and transition to new path is now seamless!
  • Fixed Path:Stop() from executing multiple times.
  • Fixed handling of more NetworkOwnership errors.
  • Added a new feature; added IgnoreTimeout parameter for Path:Run() (see api).

You should make this more compatible with bigger Humanoids. I tried using it on a character that is 1.5x bigger than the average player, and even after changing the AgentHeight and AgentRadius, the character would walk backwards to the starting node every time I would change its goal. But, I found a workaround.

path.InitialPosition = script.Parent.Torso.Position + (goal.Position - script.Parent.Torso.Position).Unit * 2

Full while loop:

local path
while true do
	path = SimplePath.new(script.Parent, {AgentHeight = 7.5, AgentRadius = 3, AgentCanJump = true})
	
	game:GetService("RunService").Heartbeat:Wait()
	local goal = FindNearestTorso(script.Parent.Torso.Position)
	if goal then
		path.InitialPosition = script.Parent.Torso.Position + (goal.Position - script.Parent.Torso.Position).Unit * 2
		path:Run(goal.Position, false)
	end
end

Update 0.25:

  • Path:Run() now returns true if the path is successful (make sure to handle this).
  • Fixed bug when pathfinding for humanoids with different sizes.
  • Removed the previous feature for IgnoreTimeout and made it built-in.
  • Fixed error that stops the Humanoid randomly.

Try now and let me know how it goes.

1 Like

Looks promising, gonna definitely check it out!

This is a pretty cool module! Just a question though, how would I make a pet (npc) that is following a player know when to jump or not?

Hey, thanks for the feedback! When you execute the Run() function, the module calculates the timeout of the rig using walkspeed and rig size. So say if the rig needs to jump in order to reach the next waypoint. In this case, it can be detected by the module when the rig doesn’t reach the next waypoint within the calculated time. If there’s a timeout, the rig jumps automatically. So you don’t need to worry about making the pet jump. It will jump itself.

Edit: I had to add this feature since roblox autojump doesn’t work always and is unreliable.

1 Like

Oh thank you! Thank you for letting me know.

Edit: Actually, I solo’d the code once and tried to make the pet jump over a gap in my game, and it didn’t jump over, it just fell off…

Oh I thought you meant if it jumps over an obstacle like an inteference blocking the path. In that case, the module doesn’t make the rig jump over gaps. It doesn’t because roblox’s pathfinding service does not support that.

Oh ok, thanks for letting me know either way.