SimplePath - Pathfinding Module

i love you glorious grayzcale :star_struck:

does simplepath have a timeout when getting stuck?

Why does my client side code does not work? Its in starterplayerscripts, it should work

local SimplePath = require(game.ReplicatedStorage:WaitForChild("SimplePath"))

local events = {
    Create = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("CreatePath");
    Start = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("StartPath");
    Stop = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("StopPath");
    Destroy = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("DestroyPath");
}
local paths = {}

local function Create(Agent)
    if Agent:IsA("Model") and Agent:FindFirstChild("Humanoid") and Agent:FindFirstChild("HumanoidRootPart") and not paths[Agent] then
        paths[Agent] = SimplePath.new(Agent)
    end
    return paths[Agent] --can be ignored for sure
end
local function Start(Agent, Destination) --specific agent to pathfind
    local path = paths[Agent]
    if path then
        print("RUNNING") --it prints but agent doesnt pathfinds?
        path:Run(Agent.HumanoidRootPart.Position + Vector3.new(math.random(15, 20), 0, math.random(15, 20)))
    end
end
local function Stop(Agent) --specific agent to stop
    print("stop called")
    if paths[Agent] then
        if not SimplePath.StatusType.Idle then
            paths[Agent]:Stop()
        end
    end
end
local function Destroy(Agent) --destroy Path (used when agent is dead) 
    print("destroy called")
    paths[Agent]:Destroy()
    paths[Agent] = nil
end

events.Create.OnClientEvent:Connect(Create)
events.Start.OnClientEvent:Connect(Start)
events.Stop.OnClientEvent:Connect(Stop)
events.Destroy.OnClientEvent:Connect(Destroy)

I wonder what makes simple path switching from pathfinding routes so quickly without much delay

I believe it does, but take quite a while

1 Like

Currently having a issue with the script, not sure if this script still is being supported but I have my Path:Run(Goal) in a while true do statement, its going to its first location but when I change the goal it doesn’t go to the other goal or even visualize it. Can anyone help?

The bool side of the system is working as when the goal is changed, the old goal’s bool is changed to false and the new one is changed to true so I know its receiving the new goal, plus I am printing the new goal which is working correctly so that side of the system is working, idk what the issue could be.

In other words, the script is supposed to run as:
When the goal’s name is 1 then don’t run the while statement anymore, if its not 1 then keep changing the goal to a number down until it is and then move to the new goal location.

Currently it works as:
When the goal’s name is 1 then don’t run the while statement anymore, if its not 1 then keep changing the goal to a number down until it is and then stay at the old goal location.

while Goal == nil or tonumber(Goal.Name) ~= 1 do -- As long as the name of Goal isnt 1 and Goal is nil then
		task.wait()
		for i, v in pairs(game.Workspace.LoadingLine:GetChildren()) do -- Folder with all the goals
			if v.Taken.Value == false then -- If the bool value in the goal is not faluse then
				if Goal == nil then -- if the goal is nil then
					Goal = v -- set the goal to v
					v.Taken.Value = true -- set the taken bool value to true
				else -- if we have a previous goal then
					if tonumber(Goal.Name) - 1 == tonumber(v.Name) then -- if v is one number smaller then our current goal then
						print(Goal, v) -- for debugging which is working correctly
						Goal.Taken.Value = false -- change the old goal Taken bool back to false
						Goal = v -- set our new goal
						v.Taken.Value = true -- set the Taken bool value to true
						print("New goal") -- also for debugging
					end
				end
			end
		end
		Path:Run(Goal) -- run the goal no matter what because a goal will always be present
	end

does simpath work with PathfindingModifier? like pathway volume or materials.

Hello just askin, but anyway this uses Params on the pathfinding? and is there anyway we can customize it? I have a custom AI and I would like to customize it since it has a humanoid, but sometimes it would just jump or move right above the walls, it also just try’s to push itself through a wall and it get’s stuck, so i was just wondering if it does have params, how do we like add our own to it?

Contributors: I’m sharing my experiences contributing to an open source path finding module called SimplePath. It makes walking easier, and not just for humanoids, with a simple solution that accurately recalculates routes on the fly when they’re obstructed. This ensures consistent navigation, thus an ideal solution for Roblox developers.

1 Like

Yes it does, just make sure to properly name the tags.

Hi, umm, is there a link to what you are open sourcing?

Thanks

Hey @GrayzcaIe, i’m having some problems with a script using your module, and someone suggested it could be the module itself. Could you check out my topic?

How would you add/enable truss climbing for simple path?

Put {AgentCanClimb = true} in AgentParams

How can i get GetNearestCharacter to work?

I cant get my npc to climb to me it just jumps off for some reason when its climbing

Hi,
Did you set the variable ScaredofHeitghts = false ?

how would I safely dispose of the path once the npc dies?

function BaseUnit.Update(self:BaseUnit): ()
	if self.Humanoid.Health <= 0 then self:destroy() return; end
function BaseUnit.destroy(self:BaseUnit): ()
	self.Destroyed:Fire()
	
	if self.Path._status ~= "Idle" then self.Path:Stop(); end
	self.Path:Destroy()
	
	for i, v in pairs(self.Animations) do
		v:Destroy()
	end
	
	debris:AddItem(self.Agent, 4)
	self = nil
end

I get errors like
ServerScriptService.SimplePath:287: attempt to index nil with 'LimitReached'
ServerScriptService.SimplePath:300: attempt to index nil with 'Status'

also I use task.spawn for path:Run

2 Likes

that isnt a thing right since i searched unless ur being sarcastic!!
??

I just did this for my game:

if Goal and Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then
	Path:Run(Goal)
end

I run my pathfinding in a loop, so if you don’t, then I’m not sure why your npc won’t climb