Skip to content

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Aug 25, 2025

Games with hexagonal maps usually want characters to move between tiles on the grid, so I added another movement option that makes the troll from tile to tile like a turn-based hex game. It still uses WASD controls (you need to press multiple keys to hit all 6 directions). Works well on gamepad too.

Additionally, the current move_and_slide troll doesn't really interact with the world, so I made it stop before leaving the grid. This also acts as a demonstration of how to get the tile id for interacting with objects represented by valid tiles.

I also converted TileMap to TileMapLayer.

No untyped_declaration warnings.

Demo:

godot-hexmap.mp4

For godotengine#1176.

Used "Extract TileMap layers as individual TileMapLayer nodes" in the
TileMap editor.

Test
* Walk around with the Troll and everything seems fine. This demo always
  allowed you to walk over empty tiles, so there's not much to the
  TileMap.
idbrii added 2 commits August 30, 2025 19:59
Games with hexagonal maps usually want characters to stay within the
grid, so add another movement option. This troll has no physics and uses
tweens to move. Instead of collision, it uses tile values to determine
where they're allowed to go.
Move troll's root pivot to line up with their collider. This makes their
global_position a good representation of where they are.

Add check for moving to an invalid tile and undo our move. In my tests,
this isn't less smooth than skipping the move_and_slide if
(global_position + velocity * dt) is an invalid tile and allows sliding
to resolve us to a slightly different position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants