# Pathfinding in a grid with vertical space

I apologize if this has already been asked, but I am a bit of a beginner to these forums.

Essentially I want to avoid reinventing the wheel if someone has already done it.

I am making a game that is similar to Final Fantasy Tactics/ Tactics Ogre /etc., except hex based instead of a square grid.

This game will have maps with abrupt changes in elevation (A house or tower, for example). How can I reasonably calculate the most efficient route from point A to point B, taking into account that some units may have the capacity to simply leap some vertical distances?

this is actually a lot easier than people often think, Especially because it’s turn-based you won’t have to worry about your pathfinding method getting over used and clogging up memory. You could write this yourself, just plan it out.

The basic concept is rather simple:

1. make sure you have your entire grid data stored and easily accessible, e.g. can you easily check if cell 207 has something that will block movement?

2. make sure you have an easy way to make and store coordinates in order to read cells, e.g., you can use Vector2Int or Vector3Int for a 3Dimensional grid.

3. to make a path from A to B, you will basically be storing a list of coordinates for travelling, e.g., cell 1, then cell 5, then cell 3, then cell 4 etc, make sure your movement will be able to read a list of coordinates (or directions) and follow it.

4. create a pathfinding method that creates a list to store the coordinates, then each loop, check the last coordinate in the list for available cells surrounding it. For each cell that can be walked on, replicate the current list and add that cell to it, and do the same process for that list. If you check one cell from each list, and cycle through them, the first list to get the end coordinate will be the shortest (or when they’re done which will use more memory, you can check the Count of each list)

it’s a good programming challenge, and I’d highly recommend giving it a try for yourself.