-
Notifications
You must be signed in to change notification settings - Fork 345
Description
Hello guys!
Im using this repo for building a Terraria like game.
My map is made by chunk of tiles. Each chunk is 64x64 tiles and have two tilemaps, one for the background and another one with the composite collider for the foreground (the composite collider is just generated manually, and I have to do it the next frame after set the tile map becouse it doesnt work on the same frame I execute the SetTilesBlock).
I instantiate 9 chunks around the player and as soon as he reachs a border of the current chunk I start loading new chunks and unloading others.
While using default tiles this is working well, but as soon as I use rule tiles the game freezes for a moment when new chunks are created (even if I set just one row of the chunk each frame).
At the moment im not storing the tilemap data, Im just generating it on the fly using a perlin noise.
These are the three steps it takes:
- Build an array of TileData. TileData contains two int, and id for the background tile and another one for the foreground. This is made using c# tasks.
- Use all the tile data for load the tiles from an scriptable object and prepare the Tile Arrays for SetTilesBlock. This is made with c# tasks too.
- Set the tile maps blocks.
For fix the lag/freeze problem it would be great to be able to prepare the tile arrays for SetTilesBlock using tasks or thread or anything than doesnt freeze the game. I know that the tilemap cant be changed in another thread, but if I was able to build the arrays with the final sprite/tile value that the rule tile is going to set (this can be done in another thread) will improve the performance enought.