Pathfinding has issues with elevation?

just whipped up a pathfinding system, it finds the nearest character fine but is this simplepaths issue where the ai doesnt make any attempt to decrease elevation and would much rather go a long way around?
this is using → Getting Started - SimplePath
or the devform → SimplePath - Pathfinding Module

-- // Creating path [ SFN.HS ]
local Path = SimplePath.new(SCP, {AgentCanJump = false; AgentCanClimb = true;})
Path.Visualize = true
Path._settings.JUMP_WHEN_STUCK = true
Path._settings.COMPARISON_CHECKS = 10

-- // Pathfinding 
--------------------------------------------------
RunService.Heartbeat:Connect(function(DeltaTime) -- // [ VNU ]
	local TargetCharacter = nil
	pcall(function()
		TargetCharacter = NearestCharacter()
	end)
	if Players:GetPlayerFromCharacter(TargetCharacter) then
		Path:Run(TargetCharacter:FindFirstChild(`HumanoidRootPart`))
	else
		TargetCharacter = nil
	end
end)
--------------------------------------------------

quality may be bad as i just uploaded it anyone viewing this reply from like 16:00pm gmt onward will see it in better quality.

1 Like

Has anyone figured out why this is?

Changing up the script the same issue still occurs:

-- // Pathfinding 
--------------------------------------------------
local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

function followPath(Target)
	-- Compute the path
	local success, errorMessage = pcall(function()
		path:ComputeAsync(SCP_ROOT.Position - Vector3.new(0, SCP_ROOT.Size.Y/0.75, 0), Target)
	end)

	if success and path.Status == Enum.PathStatus.Success then
		-- Get the path waypoints
		waypoints = path:GetWaypoints()

		-- Detect if path becomes blocked
		blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
			-- Check if the obstacle is further down the path
			if blockedWaypointIndex >= nextWaypointIndex then
				-- Stop detecting path blockage until path is re-computed
				blockedConnection:Disconnect()
				-- Call function to re-compute new path
				followPath(Target)
			end
		end)

		-- Detect when movement to next waypoint is complete
		if not reachedConnection then
			reachedConnection = SCP:FindFirstChild(`Humanoid`).MoveToFinished:Connect(function(reached)
				if reached and nextWaypointIndex < #waypoints then
					-- Increase waypoint index and move to next waypoint
					nextWaypointIndex += 1
					SCP:FindFirstChild(`Humanoid`):MoveTo(waypoints[nextWaypointIndex].Position)
				else
					reachedConnection:Disconnect()
					blockedConnection:Disconnect()
				end
			end)
		end

		-- Initially move to second waypoint (first waypoint is path start; skip it)
		nextWaypointIndex = 2
		SCP:FindFirstChild(`Humanoid`):MoveTo(waypoints[nextWaypointIndex].Position)
	else
		warn("Path not computed!", errorMessage)
	end
end

-- // Update target [ VNU ]
RunService.Heartbeat:Connect(function()
	local TargetCh = NearestCharacter()
	local Pos = TargetCh.PrimaryPart.Position
	followPath(Pos)
end)

--------------------------------------------------
  • Note to anyone who does want to look into this I have got both scripts still saved.
1 Like

I forgot to say, it bases its pathfinding on the targets humanoidrootpart and it finds the nearest humanoidrootpart.

just bumping this as it has been 2 days without response

If you have even the slightest elevation your agent will be required to be able to jump so it can traverse those sections.
If you have areas where you absolutely do not want it to traverse (like over an upstairs railing) then you’d use pathfinding modifiers to solve that.

Yes, it is true that

your agent will be required to be able to jump so it can traverse those sections.

So, you need to set AgentCanJump to true or use pathfinding links and modifiers as @Locard suggested.

1 Like

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