Pathfinding NPC gets confused on wedges

Thank you for the help! Now, I guess I can make efficient pathfinding AI!

1 Like

Hmm, tried clicking on the link for 1* Pathfinding and couldn’t find it somehow…?

Good example

Thank you.

sanjsanjasnjaNJaassas

1 Like

And by the way, I forgot to mention this, but there are functions inside of the pathfinding code (NPC) that do not appear within the example functions of the modules such as AStar.calculatePath:() and PathLearning.init()

Here are a few things you can check:

  1. Check if there are additional script files or modules that define these functions. Look for any other Lua files or modules that might be included in the codebase.

  2. Verify if there are any external dependencies or libraries being used that might provide these functions. Check the documentation or source code of any external libraries that are being used in the code.

  3. Make sure that the necessary modules or libraries are properly imported or required at the beginning of the code. Check if there are any missing import statements for the modules that define these functions.

Don’t get what your saying, sorry.

I’m pretty sure all their responses are AI generated

Wait really? Is that really true?

Yes, the grammar is super perfect and they added stuff without even telling you what it was at first. I don’t think any human would do that

C’mon, really? Damn.

Anyway, DanCodes, mind if you help me with the Pathfinding script I made?

So it seems like you’re using Simple Path. Every time I tried using that module some weird error comes up, and the owner doesn’t want to fix anything about it anymore. It’d probably be best to do your own pathfinding thing from scratch. Another thing I can think of is setting up some parts along the edges of the wedge with a specific material, and then set the agent parameters so the cost to walk along it is really high

nvm, well, thanks for the help I guess!

game:GetService("RunService").Heartbeat:Connect(function()
	local Player = FindNearestTarget()
	--//Character
	local Player_Char = Player.Character or Player.CharacterAdded:Wait()
	local Char_Root = Player_Char.PrimaryPart
	local Char_Hum = Player_Char:FindFirstChildWhichIsA("Humanoid")

	if Char_Hum.Health <= 1 then
		return
	end
	
	--//Pathfinding
	local Goal = Char_Root.Position
	local Path = SimplePath.new(NPC)

	Path.Blocked:Connect(function()
		Path:Run(Goal)
	end)
	Path.Reached:Connect(function()
		Path:Run(Goal)
	end)
	Path.Error:Connect(function(errorType)
		Path:Run(Goal)
	end)
	Path:Run(Goal)
end)

This whole section here is a big memory leak since you’re making a new connection to all the events every heartbeat

Ah okay then. How can I fix it then?

local Path = SimplePath.new(NPC)

while true do
    local Player = FindNearestTarget()
    --//Character
    local Player_Char = Player.Character
    local Char_Root = Player_Char and Player_Char.PrimaryPart
    local Char_Hum = Char_Root and Player_Char:FindFirstChildWhichIsA("Humanoid")

    if not Char_Hum or Char_Hum.Health <= 0 then
        task.wait()
        continue
    end

    Path:Run(Char_Root.Position)
end

If you keep using Simple Path you can do this, otherwise you’re going to have to look at some pathfinding tutorials

Thanks! Anyway just curious, what’s the best way to Pathfind on future pathfinding AI’s?

I’m still trying to figure that out myself, I’ll probably post a public module sometime in the future

Alright then, thanks! It now seems to work correctly.

You talked to chatgpt. and most likely there are a lot of errors