Hi there !
I am currently prototyping a 2D strategy game, like "Age of Empire", with isometric hexagonal tiles, and I am facing some memory usage issue, even if the game is far from being fully featured ^^"...
I would be really grateful if you could help me to find out the cause of it !
I will try to describe as much as possible of my prototype, without being boring.
Here is the structure of the Map
Map (Node2D) | +---> YSort (YSort) // Just for a display correctness purpose | +-----> Hexagon1 (Area2D) // <--- (a PackedScene instance) | | | +-----> CollisionPolygon2D | +-----> Sprite | +-----> Hexagon2 +-----> Hexagon3 +-----> Hexagon4 . . . +----->HexagonN
As I needed each type of tile (buildings, forest, land, etc...) to handle its custom logic I wasn't able to use the built-in Tilemap, so I decided to build my own by playing with the scene system.
Each type of tiles is defined as a Scene, where I set:
1. its sprite
2. its collision shape
3. a dedicated script to handle the custom logic.
To be able to have a good image quality when zooming on the tiles, the original sprite size is (900 x 810) pixels, and I set a default scale of (0.1 x 0.1). The different sprite elements are stored in a single texture (size ~4Mo).
So, if you followed me, a map of size (10 x 10) is basically made of 100 scene instance.
With a (10 x 10) sized map, I never encountered any memory/cpu usage problems, but my goal is to have larger map, like (10 000 x 10 000)...
But I encounter memory usage issue with only a map of size (30 * 30) !
The debugger tells me that a (30 * 30) sized map corresponds to approximately 4500 Objects, with a memory usage of approximately 350Mo... That means each object weighs ~77Ko
I really doubt that Godot Engine is not able to handle 4500 objects without blowing out my memory, so I am convinced that the problem is on my side.
Again, I would be really grateful if you could help me to find out the cause this memory usage issue !
If you need any further information, do not hesitate to ask, I may not have been very clear !
Thanks a lot in advance