Pathfinding not working

Hey!

I did not find any topics about this, so here am I :smiley:

I am using Pathfinding Service to make a humanoid move. But the waypoints are looking like this:

(The Show Navigation Mesh is active)
imagem_2022-11-16_164155498

The issue is that the waypoints are passing through the table and chair.

If you look carefully, you will see a part with 0.5 transparency, at the left of the table, that is the size of the agent in game.

Here is the PathParams:

local pathParams =
	{
		["AgentHeight"] = 7.75,
		["AgentRadius"] = 3,
		["AgentCanJump"] = false
	}

Can someone help me?

2 Likes

What is in your script for setting the waypoints?

2 Likes

Oh sorry, I forgotten this.
It is a module script called from a script.

local agentPath = PathFindingService:CreatePath(pathParams)
agentPath:ComputeAsync(Freddy.PrimaryPart.Position, newPoint.Position)
if agentPath.Status == Enum.PathStatus.NoPath then print("No path") end
local Waypoints = agentPath:GetWaypoints()
for waypointIndex, waypoint in pairs(Waypoints) do
	local choosedPlayer = canHunt()
	if choosedPlayer then
	     --HuntModule:Start()
	     print(choosedPlayer.Name)
    end
	Agent.Humanoid:MoveTo(waypoint.Position)
	Agent.Humanoid.MoveToFinished:Wait()
end
		

This Agent will chase a player if canHunt() returns a player

Let me just change a few things so the code looks more clean:

local agentPath = PathFindingService:CreatePath(pathParams)
agentPath:ComputeAsync(Freddy.PrimaryPart.Position, newPoint.Position)

if agentPath.Status == Enum.PathStatus.Success then
   local Waypoints = agentPath:GetWaypoints()
   for i, waypoint in ipairs(Waypoints) do
      local chosenPlayer = canHunt()
      if chosenPlayer then
         -- hunt
         print(chosenPlayer.Name)
      end
      Agent.Humanoid:MoveTo(waypoint.Position) 
      local moveSuccess = Agent.Humanoid.MoveToFinished:Wait(1)
    -- if not moveSuccess then
       --break (This is a check to see if the agent has truly successfully reached the next waypoint.)
    --end
   end
 else
   print("No path!")
end

You can add the check if you want.

Okay, thank you! This makes sense :smiley:

What do you mean with check?

Its an extra check to see if the agent has reached the waypoint position cuz sometimes roblox’s pathfinding checks wont work alone

Oh, ok i will add this to the script