Hello, recently i’ve been trying to make a pathfinding npc with a kinda complicated model. The thing is that for some reason, the npc gets stuck at some point even when it’s able to walk through, the pathfinding service seems to be unable to generate any path when the npc is close to an object even if the agentradius is almost at zero. Here’s a video of it:
(“Show decomposition geometry” is enabled to make hitboxes visible, that way there’s a clear vision of what’s happening)
Anyone knows why that might be happening? Here’s some parameters I use and the code for pathfinding (it uses promises and some other external things)
The agent radius set for this npc is 0.05, so I dont think that the agent radius is causing problems…
-- HEAVILY SIMPLIFIED TO MAKE IT EASIER TO UNDERSTAND
-- SCP == NPC
function Utilities.PathWalkToTarget(scp, targetPosition)
Promise.new(function(resolve, reject, onCancel)
onCancel(function()
-- Makes the npc stop when cancelled
scp.Humanoid:MoveTo(scp.RootPart.Position)
end)
local char_size = scp.Model:GetExtentsSize()
local params = {
AgentRadius = scp.Configuration.ModelRadius,--(char_size.X + char_size.Z) / 4,
AgentHeight = char_size.Y,
AgentCanJump = false,
WaypointSpacing = 4,
}
local path = PathfindingService:CreatePath(params)
path:ComputeAsync(scp.RootPart.Position, targetPosition)
if path.Status == Enum.PathStatus.Success then
local cancelled = false
local CancelCurrentMovement
for i, waypoint in pairs(path:GetWaypoints()) do
if i <= 1 then continue end -- Ignores first waypoint if there are less than 60 mobs
if cancelled then break end -- Stops loop if cancelled
if not scp._Cache.JumpCooldown then
if waypoint.Action == Enum.PathWaypointAction.Jump then
scp.Humanoid.Jump = true
scp._Cache.JumpCooldown = true
Promise.delay(0.5):andThen(function()
scp._Cache.JumpCooldown = false
end)
end
end
scp.Humanoid:MoveTo(waypoint.Position)
scp.Humanoid.MoveToFinished:Wait()
if i == #path:GetWaypoints() then
resolve() -- (ENDS FUNCTION)
end
end
else
if scp.Name == "UnknownMonster_Event" then
print("path find failed, status: ", path.Status.Name)
end
scp.Humanoid:MoveTo(scp.RootPart.Position)
resolve()
end
end)
end