SimplePath - Pathfinding Module

my npc can’t catch up to me despite having faster walkspeed?

what i have so far:
pathfindtest.rbxl (68.7 KB)

2 Likes

Hey!

There’s this issue where the NPC cannot walk over unions/meshes but only normal parts.
For an example, I cannot make the NPC walk on stairs made of meshes or unions…

Anyway to fix this?

Hey! is there a way to delete the paths after the humanoid died? because it lags my game having alot of humanoids spawn then die but the paths remaining

You can easily do:

if Path._status == "Active" then
	Path:Stop()
end

in the script where you run Path:Run(goal)

Maybe set the CollisionFidelity to PreciseConvexDecomposition. Mine goes over unions just fine.

That’s very strange…I just tried it and I’m afraid this doesn’t work either? The NPC is still having trouble to get to these meshes/unions when the targeted goal is on top of these objects.

If your referring to the goal being the player’s character, you can just make the goal the position of the humanoid root part.

Would you be able to provide a .rbxl with said mesh and pathfinder? As I cannot seem to reproduce this bug.

1 Like

I’m having trouble, my humanoid doesn’t wanna jump at all when needed to jump in order to follow the player
Here’s the code block that’s uses SimplePath:

Try replacing local path = path_service.new(model) with this: local path = path_service.new(model, {agentCanJump = true})

It didn’t help, the AI is still unable to jump when needed

Try it with the AgentHight.

local path = path_service.new(model, 
{AgentCanJump = true,
AgentHight = 7.5}
)

What is the JumpPower of the AI set to?

Sorry for the late reply, it seems like we are different timezone, the AI JumpPower is set to 50

Didn’t work, still the same error, the AI just stops when he needs to jump to get to the player

One more thing to try, if this doesn’t work then I honestly don’t know.

find these lines with this function, should be around line 184

--Compute path
local pathComputed, _ = pcall(function()
     self._path:ComputeAsync blah blah blah rest of code
end)

and replace it with this:

--Compute path
local pathComputed, _ = pcall(function()
	self._path:ComputeAsync(self._agent.PrimaryPart.Position - Vector3.new(0, self._agent.PrimaryPart.Size.Y/0.75), (typeof(target) == "Vector3" and target) or target.Position)
end)

It works, but it was around like line 200+ not 184

Well thats good! I was assuming that you didn’t modify the module at all, so usually it would be around 184.

Alright, is there a way I can make the NPC also rotate in the players direction? For example, he would just try to go to the player instead of also rotating. if I did CFrame.lookAt the NPC doesn’t want to move and just jumps in one place

I’m having an issue with the paths and the stop feature. Is it possible for the code to know the difference between paths between when I stopped one path, it stopped every path and I don’t know how to fix it.
EDIT: I’m also having an issue where there might be too many npcs going to the player because the npcs start to back track or just don’t want to follow the player at all