Im having an issue with my large scale pathfinding. The map is not changing, the point the enemy has to go to is not changing. The only thing that changes is the path params Costs table.
I thought it could be the Costs table, but every time a path is failing the Costs table is completely changed and it attempts the path again. Sometimes the enemy moves perfectly fine 5-6 times in a row, and sometimes randomly the enemy spawns and just wont move at all, and sits on a constant loop of computing broken paths. I have seen the enemy compute paths multiple times in every area of the map. Is there just a max distance limit to pathfinding?
This is the primary path compute, and its returning nil error only sometime.
Its erroring when it calls ComputeAsync.
function ComputePath(v,model)
local possible = {"Plastic","Neon","Grass","SmoothPlastic","Glass","Foil","DiamondPlate","Metal","Granite","Brick","WoodPlanks","Slate","Wood","CorrodedMetal","Marble","Concrete","Fabric","Pebble","Sand","ForceField"}
local pathParams = {
AgentRadius = model.HumanoidRootPart.Size.X,
AgentHeight = model.HumanoidRootPart.Size.Y*2.5,
AgentCanJump = true,
AgentCanClimb = true,
WaypointSpacing = 4,
Costs = {
Climb = math.random(45,75), -- climb my bois.
Water = math.random(25,75),
Danger = math.huge,
},
}
for i,v in pairs(possible) do
pathParams.Costs[v] = math.random(1,100)
end
print(pathParams.Costs)
local newpath
local success,err = pcall(function()
newpath = G.pathService:CreatePath(pathParams)
end)
if success then
local function compute()
v["Path"] = newpath
local success1,err1 = pcall(function()
v["Path"]:ComputeAsync(model.HumanoidRootPart.Position, v["TargetPart"].Position)
end)
if not success1 or v["Path"].Status ~= Enum.PathStatus.Success then
v["Path"] = nil
warn(err1)
end
end
compute()
else
warn(err)
v["Path"] = nil
end
--if v["Path"] == nil then
--if not v["FailedPath"][v["TargetPart"]] and model:findFirstChild("friendlyHandler") == nil then
--print 'not in the table yet.'
-- v["FailedPath"][v["TargetPart"]] = true
-- end
--end
end
Enemy creating a proper path on spawn.
Enemy getting stuck on spawn
The area just below.
The objective area he is pathing to.