TileMap grid line display at runtime

Godot Version

Godot 4.2

Question

Godot has many ways to do something, some better than others. What is the best (fastest, most efficient, whatever) way to render grid lines? Options i’ve seen:

  1. Manually call draw_line() a ton of times on every frame.
  2. Create another tilemap filled with tiles that are blank but with edges.
  3. Maybe there’s a way to do #1 on level load but save the result?
  4. Maybe 4 finally added a built-in way?

1 seems time expensive, 2 seems memory expensive, but computers have lots of both so maybe there’s no point in worrying about it.

i’m working on a tower defense. Single screen (not some huge RPG map that scrolls). Whole background is tilemap but only some of it is the playing area (which i guess only the map designer knows). In my perfect world you could draw lines only on the playing field, the player could toggle them on and off and you could color/tint each tile (you can build here but not here). Which maybe means i should do the #2 option. Sure feels manually intensive and error prone though. Wonder if i could automate that?

1 Like

draw_multiline() maybe?
Or if you have a set screen size just draw a grid of that size in a graphics program and load it to a Sprite2D.
Make that visible/not visible as needed.

1 Like