0 votes


i want to make a tile-based game and the tiles have certain properties called TileType. So i inhereted Tileset with an additional Array which is basically a function from tile id -> TyleType. A TileMap script is iterating through the used cells and building a Dictionary which is a function like tile coordinates -> TileType. This works quite fine and allows me to make changes on the map and the TileTypes are always correct, but it seems unnecessary to build this tile coordinates -> TileType Dictionary at run-time.

Is there a way to build a Resource when the project is run/build? If so, the dictionaries only need to be build once and are instantly accessible for every map.

PS: Why is mother a sugegsted tag for my issue? That's super weird...

Godot version 3.2.2
in Engine by (14 points)

1 Answer

0 votes

Yes, you create a custom resource that manages whatever information you need and assign it to the classes that require it.

That said, aren't you essentially duplicating the information in the grid? i.e. the tile map is the information that's built in the editor. You just need to provide a wrapper around this; putting it in a dictionary is essentially duplicating information (and thus memory).

by (1,104 points)

Thanks for the answer but:

  1. my question was if the resource can be made when i run the game in the editor or build the game

  2. retrieving the information from the tile itself is more computatinal heavy, because there has to be more references followed and i don't know how the information is alligned in the memory and i have to get to the tile type very frequently. Sure, that would double a couple of bytes, but with the additional resource, i can allign the information in a way, that less references have to be followed and the tile types are are in sequence in memory, leading to less cache misses and stuff. That's a good trade

I guess you could derive a custom node (or plugin) from the tile map and use your new type as a drop in replacement, if that makes sense. Possibly, sure!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.