PathfindingService Not Working

Hello all, I’m working on a very sophisticated pathfinder for a game I am working for, and I notice that it makes incorrect calculations a lot and sometimes attempts to run into the wall. I have no idea what it is; my only guess could be that I am setting the agent radius incorrectly. The rigs for the game I am working on will be set with different scale values, so I am calculating my agent radius/height for each agent that way. Here is a video demonstrating my issue:

Code I am working with:

-- Code updates every second, the module is based on the Roblox documentation.
local Pathfinder = require(game.ServerScriptService["Grmln's (Using Custom)"].Pathfinder)

local Path = Pathfinder.new(workspace.Rig)
Path.Visualize = true

local Character = workspace:WaitForChild("FyreeIG")

Path:Run(Character.HumanoidRootPart.Position)

while task.wait(1) do
	Path:Run(Character.HumanoidRootPart.Position)
end

Path.Reached:Connect(function()
	print("Reached!")
end)
-- Calculating agent radius/height based on the HumanoidRootPart Collision Model Size and the Model Scale.
local function ScaleToHitboxHeight(Scale : number)
	return math.ceil(5 * Scale)
end

local function ScaleToHitboxRadius(Scale : number)
	return math.ceil(2 * Scale) -- default collision model XZ for character root is four, agent radius is that divided by two * scale
end

Please let me know if you have any suggestions/possible fixes for this issue. Thanks!

Maybe because it updates every second, what I usually do is update it every 0.1 seconds.

No, that is not the issue. It doesn’t matter the time in between each iteration since the path is calculating incorrectly most of the time. Two issues occur:

  • Once the distance between the agent and destination get too close, each new path generation is just a straight line to the character.

  • The agent can stutter uncommonly, but it is also due to to the fact that the path generated is sometimes incorrect.

I think that agent radius is broken and generally doesn’t work with larger rigs. :person_shrugging: