Terra A* Pathfinding
Posted: Sat Jul 02, 2016 11:15 pm
Yes, I know people have done it before, but I really wanted to create a pathfinder myself, so here it is!
It's my Lua pathfinder called Terra! (It's pronounced like Te-ha) And it's pretty easy to use, here's a tutorial:
First of all, you need to have a map and a player!
Then you have to set the list of tiles you can walk, the starting position and the finish position.
Now you can start pathfinding!
Getting the character to move along the path:
TODO: Add corner avoidance
If you find any bugs, please tell me
It's my Lua pathfinder called Terra! (It's pronounced like Te-ha) And it's pretty easy to use, here's a tutorial:
First of all, you need to have a map and a player!
Code: Select all
MightyMap = {}
MightyMap[1] = {0, 1, 2}
MightyMap[2] = {0, 2, 0}
MightyMap[3] = {0, 3, 0}
player = {y = 1, x = 1}
Code: Select all
terra.setWalkableNodes{2, 3}
terra.setStartingNode(y, x)
terra.setTargetNode(y, x)
Code: Select all
path = terra.pathfind(MightyMap)
Code: Select all
step = 1
function love.update(dt)
player.y, player.x = path[step].y, path[step].x
step = step + 1
end
If you find any bugs, please tell me