NPCs get stuck on steep slopes with pathfinding

example: https://gyazo.com/0f31ce2f845660f6b568b3ce69724e3a
had to cut the gif since I could only record up to 7 seconds but pretty much the second I lure the NPC on that slope he just starts running up it.
Not to mention its literally impossible to reach me from going up the slope since the top is this:
image

My pathfinding code:

local PathfindingService = game:GetService("PathfindingService")

local function PathFind(humanoid,StartPos,Destination)
	local path = PathfindingService:CreatePath({
		AgentHeight = 3
	})
	
	path:ComputeAsync(StartPos,Destination)
	
	local waypoints = path:GetWaypoints()
	
	local num = 3
	local waypoint = waypoints[num] or waypoints[#waypoints]
	
	if waypoint then
		if waypoint.Action == Enum.PathWaypointAction.Jump and humanoid.FloorMaterial ~= Enum.Material.Air then
			humanoid.Jump = true
		end
		
		humanoid:MoveTo(waypoint.Position)
	end
end

return PathFind

Any help is greatly appreciated! I’m stumped on how to fix this.

Destination is the position of the player the NPC is running after.
Pathfind gets called in a heartbeat loop while chasing.

I’ve tried messing with the material priorities and this issue still occurs. I have no clue what to do to fix this and its a serious problem in my game.

I think there’s a property under Humanoid that shows the MaxSlopeAngle or something

1 Like

Thats the angle of the slope the humanoid can walk up. They can walk up these slopes completely fine. The issue is the AI breaking and for some reason concluding that it cannot go down the slope.

I believe the solution to this would be to raycast and get the slope angle. If its at a certain angle we just use MoveTo() without any pathfinding. This is the only way to fix this I believe.

1 Like

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