Hello! I am making a Pokémon Mystery Dungeon remake (I do not plan on releasing it, it’s just a passion project). And the main gameplay gimmick is tile-based, turn-based movement.
And I am having trouble figuring out how to implement pathfinding for the enemies because the way I set up the tile based movement was using actual parts as tiles (see image below). And models that tween to the nearest tile the player is trying to go.
And I don’t know how to keep the pathfinding contained within those tiles as most of the pathfinding modules or script I’ve found bug out when I apply them to this.
you can use a for loop and store waypoint positions for each part in a table
local waypoints = {}
for i = 1, #partsFolder do
if partsFolder[i]:IsA('BasePart') then
table.insert(waypoints, partsFolder[i].Position)
end
end
Then when parts get removed from the waypoint parts folder, you can use a script connection to remove the stored waypoint(s).
partsFolder.ChildRemoving:Connect(function(child)
if child:IsA('BasePart') then
local findInTable = table.find(waypoints, child.Position)
if #partsFolder > 0 then
table.remove(waypoints, findInTable)
else
for i = 1, #waypoints do
table.remove(waypoints, i)
end
end
end