SimplePath - Pathfinding Module

Thank you, this works perfect for my game!

Alright I’m here to report a bug I’ve been having for a while;

Without rhyme or reason, the AI will sometimes move back and forth between the previous and current waypoints. I’ve tried to replicate this issue but to no avail. Perhaps you could take a look into the module and investigate? Thanks.

1 Like

How do I use it? It doesn’t work?

--Import the module so you can start using it
local ServerStorage = game:GetService("ServerStorage")
local SimplePath = require(ServerStorage.SimplePath)

--Define npc
local Dummy = workspace.Dummy

-- Define a part called "Goal"
local Goal = workspace.Target

--Create a new Path using the Dummy
local Path = SimplePath.new(Dummy)

--Helps to visualize the path
Path.Visualize = true

while true do
	Path:Run(Goal)
end

no errors, no path seen, nothing

image
hello, why is this happpening to the script? i tried to find an error and it leads to the module

This is happening to me too, with the use of PathfindingLinks. I’m gonna try to fix it

Edit: think I almost got it. I added a check if the third waypoint is further away and if it is, i set the current waypoint to that. seems to work

Edit 2: i got it working in a pretty good state. if anyone wants to try my version just message me

You are a god, Thank you so much!

Alright… after tinkering for a bit with the module I believe I have found a solution to the bug where AI would just walk back and forth…

I’m not 100% sure, the units still stutter a bit, but at the very least they will get to their designated points appropriately and on time.

SimplePath but maybe fixed.lua (11.8 KB)

What I did was every time the path:Run() is called, it’d check the new waypoints for the closest waypoint to the agent. It’d then return the number ID of that waypoint, and set that as the starting point. Not the greatest or most efficient solution but it works for now.

4 Likes

Do you have a Dummy and a Target in Workspace? Where do you have put the module? If it’s in ReplicatedStorage you need to change “ServerStorage” to “ReplicatedStorage”. If you haven’t done these things, then it’s no wonder it doesn’t work.

I got it to work a long time go, but how do I use it with non-humanoid npcs, like a car?

I should’ve used this sooner instead of coding pathfinding AIs from scratch. It’s just that good.

Life-saving module, great job!

Good day,

The module is not working at the moment, I copied the example code and the latest module from Github into a module in replicatedstorage, with a part in the workspace called Dummy and when I run nothing happens and no errors.

local SimplePath = require(game.ReplicatedStorage.SimplePath)

--Define npc
local Dummy = workspace.Dummy

-- Define a part called "Goal"
local Goal = workspace.Goal

--Create a new Path using the Dummy
local Path = SimplePath.new(Dummy)

--Helps to visualize the path
Path.Visualize = true

--Compute a new path every time the Dummy reaches the goal part
Path.Reached:Connect(function()
	Path:Run(Goal)
end)

--Dummy knows to compute path again if something blocks the path
Path.Blocked:Connect(function()
	Path:Run(Goal)
end)

--If the position of Goal changes at the next waypoint, compute path again
Path.WaypointReached:Connect(function()
	Path:Run(Goal)
end)

--Dummmy knows to compute path again if an error occurs
Path.Error:Connect(function(errorType)
	Path:Run(Goal)
end)

Path:Run(Goal)

Found out it does not like “Build Rig” NPC’s but does work with others, why would this be the structure looks good.

I’m currently having issues with this module as well, sadly I believe it isn’t maintained anymore.

an older version of the module on the github seems to be working for me right now, hope this module gets updated because its really useful

I don’t have any issues with the build rig, Could you check if the character is unachored?

1 Like

It is still maintained, What is the issue?

This is my primary issue, the module makes NPC’s jump between nodes when stuck, sadly it’s making it jump to the defective node and the next in the queue repetitively which gives it a “wall hugging effect”.

At this point, I messaged the creator twice and yet no response on a resolution which led me to believe it isn’t maintained anymore.

You could set “jump when stuck” to false at the module only thing bad is if it’s stuck then it won’t jump, You could try it.

The only thing Jump When stuck does, is making the Humanoid literally jump in an attempt to find another path which it can travel, in my case it’s useless as whether it jumps or doesnt jump, it shouldn’t be stuck.

There’s a clear path between NPC and Player, yet the module constantly bounces between defective travel nodes.

I don’t believe there is a fix for this that’s easy else the owner would’ve responded to me when I messaged him.

Ow, That hurts. I don’t also have any fixes with it, But the pathfinder also sometimes jumps even if it’s a clear path, I checked the navigation mesh and there’s nothing blocking it.