Finding Adjacent Tiles In Isometric

Godot Version

4.1.1

Question

I’m developing a game in isometric, where for placing compatibility reasons, I must check the source id of the tiles directly adjacent to a tile in a tilemap (Sprites).

The issue is: depending on where the tile is in the tilemap, the algorithm for finding adjacents seems like it would need to be different due to the fact that the slope of the tiles is that for every two values of x, the y value increases by one.

Examples:


Notice how in one, two target cells have a larger x value than the original, and in the other, they’re smaller.

Thanks for your help.

The TileMap class actually has a handy utility function for this: get_neighbor_cell().

Isometric tiles have these neighbors:

TileSet.CELL_NEIGHBOR_RIGHT_CORNER
TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE
TileSet.CELL_NEIGHBOR_BOTTOM_CORNER
TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_SIDE
TileSet.CELL_NEIGHBOR_LEFT_CORNER
TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE
TileSet.CELL_NEIGHBOR_TOP_CORNER
TileSet.CELL_NEIGHBOR_TOP_RIGHT_SIDE

Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.