Help with optimizations

Godot Version

4.2

Question

Hello! I’m trying to make a game where nations fight over territory. I’ve come across an issue with optimization however. As the game isn’t using the tilemap, each tile is its own object and that is causing quite a bit of lag. However, using the tilemap will be difficult as I want the nations to each have their own color without adding it in a tileset. If anyone can help out, thanks!

(Sorry if im explaining this poorly, im new around here :P)

You can create alternative tiles inside your TileSet with different properties like the modulate color for example Using TileSets — Godot Engine (stable) documentation in English

1 Like

Can I edit them through code?

You can edit the tiles themselves in the TileSet (so every tile will be updated) or implement TileMap._use_tile_data_runtime_update() and TileMap._tile_data_runtime_update() to update the tiles in the TileMap at runtime (only the tiles you update get updated)

Thanks! One last thing.
Is it possible to store data or code on the tiles?

It depends what kind of data. If it’s static data that you won’t modify at runtime then, yes, you can save custom data for each tile in the TileSet. If it’s data that you will be changing then no, it’s not possible and you’ll need to keep that data separated.

I see, thanks for all the help!
I’ll try implementing your solution and ill let you know if it works