GridMap or manually instantiate a grid?

Godot Version

4.5

Question

Hello! :waving_hand:

I’m trying to figure out if a GridMap is right for my use case.

  • I’m currently working on a turn-based game where players + structures occupy cells on grid; players shoot at each other, and bullets have unique interactions with different types of structures.
  • The map is generated at random; it starts as a baseline room (flooring surrounded by walls) and flooring gets replaced with structures randomly at the start of the game.
  • Throughout the game, players are able to move to different cells as well as build/destroy structures throughout the game.
  • Currently, the map is 12x12, but it may grow/shrink in the future.
  • Not a requirement today, but I may want to provide players a map builder in the future.

A GM works for this, but I have a couple of concerns.

  1. It’s just a single, small room; there isn’t a real performance benefit using a GM unless the map were to grow. I’m also not building multiple unique + static levels.
  2. There are some QoL features I’d want to add later like animations for building/destroying or UI elements (like hovering cells or overlaying valid/invalid moves), and it doesn’t appear there’s any support for this within a GM. I would have to build this functionality outside of the GM but then tightly couple the two systems.

Alternatively, I could build the grid myself at start by leveraging a “cell” scene that has structures as children whose visibility I toggle, and with a normal scene, I’m able to use all of Godot’s features.

Thoughts? Is this a good use case for a GM? What is a good use case for a GM? Am I over or underestimating the abilities of GMs?

Generally GridMaps are good at instancing meshes(!), lots of them.
Any logic is decoupled and need to be separate to your GridMap (you can’t attach scripts to tiles).
So if you want to run animations on tiles, I think you need to use a custom grid that can spawn Nodes.

I used it as a ground/environment grid to check the tile types at certain coordinates.
Other than that I would love to here some use cases, too.