TransWikia.com

2D Grid-based Pathfinding with Elevation

Game Development Asked by oyed on December 11, 2021

I’m creating an isometric game which currently uses A* Pathfinding on a basic grid representation of the map.

Having elevations and allowing the Players to traverse up-and-down is an integral part of the game – however I’m stuck on exactly how to implement that, whether it be with A* or something else.

For example,

---------------------------------
| 0 | 0 | 0 | X | 0 | 4 | 4 | 4 |
---------------------------------
| 0 | 0 | 0 | 0 | 0 | 4 | 4 | 4 |
---------------------------------
| 0 | 0 | 1 | 2 | 3 | 4 | 4 | 4 |
---------------------------------

Assuming X is the Player, the numbers are tile elevations, and that the Player can only traverse tiles +/- 1 elevation to the tile they’re currently on, is there an accepted/known way of doing this pathfinding?

One Answer

Inside your A* algorithm, you have a loop where you iterate over the reachable nodes neighbouring the current node under inspection. If the elevation disparity between the two nodes is greater than your threshold, it is not reachable. You skip over that neighbour, so the algorithm doesn't try traversing the edge between these two nodes.

It might help if you edit your question to elaborate on where specifically you've run into trouble incorporating this elevation check into your particular A* implementation.

Answered by DMGregory on December 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP