My IA can't detect doors or some things

I am testing an artificial intelligence that marks where it has to go but when I put it to work it does not detect the doors and stays glued to the wall, what do I do?
image
image

My code here:

local dummy = script.Parent

local ball = workspace.PathFindBall

for _, object in pairs(dummy:GetChildren()) do 
	if object:IsA("BasePart") then 
		object:SetNetworkOwner()
	end
end

local pathfind = game:GetService("PathfindingService")


while wait() do
		
		function createPath(target)
			local Agentparams = {
				AgentHeight = 1,
				AgentRadius = 1,
				AgentCanJump = false
			}

			local path = pathfind:CreatePath(Agentparams)
			path:ComputeAsync(dummy.HumanoidRootPart.Position, ball.Position)
			if path.Status == Enum.PathStatus.Success then
				local waypoints = path:GetWaypoints()
				return path, waypoints
			end
		end
		
		function showpath(path)
			local waypoints = path:GetWaypoints()
			for _, waypoint in ipairs(waypoints) do
				local part = Instance.new("Part", workspace)
				part.Shape = Enum.PartType.Ball
				part.Material = Enum.Material.Neon
				part.Anchored = true
				part.CanCollide = false
				part.Size = Vector3.new(1,1,1)
				part.Position = waypoint.Position
				game:GetService("Debris"):AddItem(part, 5)
			end
		end
		
		
		
		function MovePathFind()
			local target = ball
			if target then
				local path, waypoints = createPath(target)
				if path and waypoints then
					local showthepath = showpath(path)
					for _, waypoint in pairs(waypoints) do
						local positionway = waypoint.Position
						dummy.Humanoid:MoveTo(positionway)
						
						dummy.Humanoid.MoveToFinished:Wait(5)
						
					end
				end
			end
		end
	MovePathFind()
end

1 Like

You could possibly make it so when the NPC touches the door. It becomes uncollidable for a few seconds.

1 Like

is that there are 2 paths, one long without obstacles and the other short with the door, but the npc goes the short way because the pathfind does not detect the door and i cant made the npc uncollidable

or is there any way to stop humanoid:movetofinished:Wait()?

I didn’t mean for the NPC to become uncollidable, I meant for the door to become uncollidable for a few seconds.

2 Likes

the same if I do it it would be impossible because all the npcs would do the same and attack the players regardless of the “security”

I think you can have it work if you put a PathfindingModifier inside the door and enable PassThrough.

2 Likes

i tried it but i got the same result


image
image

  1. I think setting the cost of something to math.huge essentially marks it as impossible to traverse. I assume that you want it to go through the door, so set it to something like 1.
  2. PassThrough should be set to true if you want the ai to act like it can walk through it.
  3. Set the parent after setting all the properties; it’s more performant.
1 Like

Setting PassThrough to true will probably help.

1 Like

you know how can i prevent this?
image

Prevent what? The path going through the tiny slit?

I want to prevent the npc from getting into places so small that he can’t get through

Set the agent radius higher, maybe to 3?

it doesnt works, if i increase or decrease the radius is the same