SimplePath - Pathfinding Module

Not sure I completely understand what you’re asking.

A path can be stopped using Path:Stop() when the dummy is moving and pathfinding.

is there a way to check if a path exists for a character? and a way to get the path for a character without having the variable

1 Like

I get a warning if I try to stop the dummy from moving and pathfinding. for some reason, the idle state is still activated…?

Good day,

Great Module, how would you code multiple destinations such as Part1, Part2 etc and constant loop between theh two parts.

Thanks

From the API for Path:Run():
“This method returns true if path computation was successful. If it returns false , the Path.Error event is fired with a ComputeError . This method automatically yields if the elapsed time between consecutive calls is less than Settings.TIME_VARIANCE .”

Im not entirely sure what you mean by this. What variable do you mean?

1 Like

You’ll get a warning if you attempt to stop pathfinding when the NPC is stopped and in idle state. Only use the Stop method when the Path status is active.

You can do something like this:

local SimplePath = require(game:GetService("ReplicatedStorage").SimplePath)
--Three parts in workspace named: "Part1", "Part2", "Part3"
local Path = SimplePath.new(workspace.Dummy)
while true do
	for i = 1, 3 do
		Path:Run(workspace["Part"..tostring(i)].Position)
		Path.Reached:Wait()
	end
end

That’s what I assume tho, I try to stop the pathfinding even tho my NPC is not in idle state… And still detect’s as idle.

Like if I make a local variable1 = path.new(NPC1) is there a way to get path.new(NPC1) if you don’t have access to variable1?

Interesting behaviour. I haven’t seen something like this happen before. What is your pathfinding code?

Can someone please help me? I get this error when using the module for some reason.

new is not a valid member of ModuleScript "ServerStorage.Modules.SimplePath"

Can you add a function to make your own path,ie :moveto but with checking if reached?,because well I want to do a tower defense game and my npc stop before reaching the waypooint that i placed,and my code is very long to solve that.Thankyou

Make sure you require the module properly like this:

(From the docs)

--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.Goal

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

If your NPC stops before reaching the goal, you might want to consider checking for errors using the Path.Error and make sure nothing is blocking the path.

I want to use this on the client, i have a mob that chases a player locally (nobody else sees it, the mob is on the client only)

I am reviewing the code, but is there anything known that would prevent me from keeping the module in ReplicatedStorage and using in on the client?

Not at all. You can use the module completely on the client.

1 Like

Is there a way to specify for humanoid pathfinding what size the humanoid is and what their walk speed is? This is a great module but only really works with normal-sized players at first glance. Please correct me if I’m wrong.

SimplePath does not use a custom pathfinding algorithm. Instead, it uses Roblox’s own PathfindingService. The waypoints generated with SimplePath are exactly what would’ve been generated with PathfindingService. Additionally, like PathfindingService, you can pass in agent parameters to the constructor of the Path for custom humanoids. Take a look at the api for more information on how to use this.

That’s actually very intuitive. Thank you for pointing that out.

Are there any parameters I could change to affect the pathfinding for humanoids with faster or slower walk speeds? After accounting for their sizes in the script, they still struggle sometimes with footing and jumps if they’re really fast or really slow.

EDIT: Here’s some examples of what I mean:
robloxapp-20220113-1659576.wmv (1.0 MB)
robloxapp-20220113-1701430.wmv (1.1 MB)

Nice module really simple way to use path finding! But I have a question by pathfinding with non-humanoids what does it mean and how will it work compared to you know using a humanoid?-Are there more options with the non-humanoid that is using this rather than a humanoid?