Pathfinder: A pathfinding character control module for NPCs

Heya! Stumbled across this module today, wanted to ask for some help regarding the “AbilitiesTable”

The ability is not running at all for me. And upon play testing it
gives me this error:

ServerStorage.Pathfinder.PathfinderClass:141: attempt to perform arithmetic (add) on number and nil  -  Studio
  23:27:12.448  Stack Begin  -  Studio
  23:27:12.448  Script 'ServerStorage.Pathfinder.PathfinderClass', Line 141 - function checkAbilities  -  Studio
  23:27:12.448  Script 'ServerStorage.Pathfinder.PathfinderClass', Line 211  - 

My code:
 local p = Pathfinder.new(PrimaryPart.Parent, {
           Target = target,
           MovingTarget = false,
           MovingTargetTrackingRange = 100,
           DebugMode = true,
           RandomMove = false,
           DebugWaypoint = true,

           AgentParameters = {
               AgentRadius = 4,
               AgentHeight = 6,
               AgentCanJump = false,
               AgentCanClimb = false,
               PathSettings = {
                   SupportPartialPath = true
               },
               Costs = {
                   -- PathfindAvoid = 9999,
                   -- Truss = 1
               }
           },

           AbilitiesTable =  {
               {
                   ActivationRange = 9,
                   ActiveTime = 5,
                   CooldownTime = 10,
                   CustomConditions = function(t)
                       warn("owowwo")
                       return true
                   end, -- optional
                   Callback = function(t)
                       warn(1234, t)
                       -- t.Character, t.Target and t.Distance are available
                   end,
               }
           } :: PathfinderAbilities

       })
       p:Run()

Can you add a Weight key to the ability? This should ideally be optional but maybe it’s missing the default right now.

Super! I tried adding it earlier but I guess something didn’t go as planned, now it works!

1 Like

Hey! I recently found this resource! I’m wondering if there’s a way of making the NPC move randomly without having to set a moving target

Been looking for a pathfinding module for a while now that is up to date and has customizations.
This might be one of the best i seen for a while Amazing resource 10/10

1 Like

Hey sorry for the late reply, I had lots of exams and stuff in between. The random move ability is for non-reachable or out of range targets. Technically you can set a moving target which is impossible to reach and trigger this yourself, however there’s not a direct way since the module is intended to be used for pathfinding.

Version v0.2.3

  • Added typing for public and private methods
  • Added character state tracking & GetState method
  • Changed OnIdle behavior to only fire when the state changes to Idle
  • Added a new event OnMove which only fires when the character begins to move
  • Various typing improvements

Additionally, restored access for the Creator Store module.

3 Likes

:Run() doesn’t work with one of my custom rig :frowning:


i’m trying to figure out why

What happens exactly? The module almost uses nothing other than the Humanoid, so the issue is likely with your character setup. I’d first check if your Humanoid dies right away, that could be the cause.

i fixed it now, however im wondering,

why is the path made like that ? can’t it detect that there will be obstacles blocking the way and can’t the module do anything about it ?

The module does detect obstacles (see the example place) since that’s a basic PathfindingService behavior. It’s similar with vanilla PathfindingService in that case, so more than likely your obstacles aren’t set properly.