I’m creating a procedural generator for 2d levels. I start with a block of 200 x 200 tiles, and carve out rooms. The problem is that my tiles are blocks with colliders, and having that many of them is clearly a bad idea. I tried removing the colliders, but it’s still just too many objects. What is a better way to solve this?
A lot of tile based engines attack this problem by recycling tiles. That is to say, store the data for all of your tiles, but then only create enough tiles as actual objects to cover the screen (plus a bit of padding room each side). Then as you move through the level and tiles go out of bounds on one side, you have the tile object jump to the opposite side right next to the other tiles as they slide into view and then reset/reinitialize the tile with the data of the new tile that it is representing.
That way you massively cut down the amount of tiles you’re actually having to instantiate.
Alternatively depending on the type of game, if the tiles once carved out are not then changed at run time, you could attempt to process the level prior to building and bake the level down into less objects. How you would do this would depend entirely on what sort of game you’re making and how your game works.
Hope this was a useful suggestion.