Hi!
I’m making a random game with pathfinding, I’ve added a pathfinding Modifier into the baseplate, to prevent the NPC thing from going on it.
What do you want to achieve? I’m just trying to get my NPC (red block thing, that is present in the video below) to pathfind to the destination, the first part of the video is the yellow block. Then I click on one of the coloured boxes, that sets the new destination.
What is the issue? It works on pathfinding to the first part, but after it. For some reason it bugs out and just stops working, when it clearly works. Video here: Video
What solutions have you tried so far? I’ve checked the dev forum, can’t find anything related to the problem. I have put more blocks surrounding the yellow box so that the NPC can pathfind all around it.
I’m very confused about why this is happening, as it works perfectly on the way there.
Any help would be greatly appreciated!
The script that controls the NPC is located in the NPC model & is in workspace. I’m unaware of the network owner, I can set it to nil? (or is it meant to be a different one)
After a lot of testing, I have located the problem. You need to reset certain variables (as in each cycle they must be either 0 / nil in order to function.) If you having a similar issue, make sure to add this function, and call it before you call your main followPath (or equivalent) function, to reset.
local function reset()
waypoints = nil
nextWaypointIndex = 0
reachedConnection = nil
blockedConnection = nil
return true
end