Zombie pathfinding acting weird and wont climb truss

External Media

I am making a zombie pathfinding system but the zombie acts like in the video above and also does not climb trusses despite having the params set to be able to climb the truss.

local Zombie = script.Parent
local Humanoid = Zombie.Humanoid
local HRP = Zombie.HumanoidRootPart

local PS = game:GetService("PathfindingService")

local function FindClosestPlayer()
	local dist,player = math.huge,nil
	for i,v in pairs(game.Players:GetPlayers()) do
		local plrdist = v:DistanceFromCharacter(HRP.Position)
		if plrdist <= dist then
			player = v
			dist = plrdist
		end
	end
	return player
end

local function Walk()
	local Player = FindClosestPlayer()
	if not Player then return end
	coroutine.resume(coroutine.create(function()
		local Character = Player.Character
		local PlayerHRP = Character.HumanoidRootPart
		local Path:Path = PS:CreatePath({AgentCanClimb = true,AgentRadius = 4,WaypointSpacing = 2, 
			Costs = {
				Props = math.huge
			}})
		local S,R = pcall(function()
			Path:ComputeAsync(HRP.Position,PlayerHRP.Position)
		end)
		if S then
			local waypoints = Path:GetWaypoints()
			for i,v:PathWaypoint in pairs(waypoints) do
				Humanoid:MoveTo(v.Position)
				if v.Action == Enum.PathWaypointAction.Jump then
					Humanoid.Jump = true
				end
				Humanoid.MoveToFinished:Wait()
			end
		else
			print(R)
		end
	end))
end

while Humanoid.Health > 0 do
	Walk()
	wait()
end
1 Like

Could there be a problem with the cost, e.g the truss is in “Props” or if you did change it, the can climb cost is higher than its wanted to be. (can climb cost is 1 by default)

The truss is not in “Props” even if it was the AI still did not respect it. As it went on climbing “Props” and got stuck.

Not sure what the problem could be, it should be working. Is the AI making an attempt to jump, or just not trying to

Just not trying to do anything.

As a debugging thing, why dont you make the path visible to see what it is doing

The issue was that Roblox not so intellegient pathfinding can not navigate tilted trusses.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.