New tiles and object pooling(ish)

I worked out that to travel 1000km I would need to create a level that has 84 tiles and it would be nice to have a bit of variation so this week I’ve added quite a few new tiles. There is now two section types, Town and Farm plus a water section thats a useful milestone marker for the player. So far I have 15 individual farm tiles, 21 town tiles and a few odds and sods, add to that there are 4 special areas with more complex details that just to give a bit more variety. I may also be able to rotate these tiles 180 degrees which will double the variation.

As an optimisation I thought I’d try and have all the available tiles in the scene from the outset and place them behind the camera, then when one needs to be displayed I could just move it into position instead of instantiating a new tile every time.

When I tried the new farm tiles I ran into a bit of a problem. In the images below you can see some of the tiles I have created and there is a lot of duplication of models in some. e.g. crops, there are 3 different variations of crop in my model pack but I thought batching would help keep performance up.


When I ran the game on my iPad 3 I noticed slow down to almost 30 fps in certain areas so I went back to the unity editor and did some profiling. During these slow points I could see that the draw calls and batching shot up from the usual 50ish & 100ish to 200 & 220.

To get around this I wanted to combine the meshes. The asset store had a few solutions to choose from and I opted for the Mad Mesh Combiner and after a bit of fiddling I managed to combine the crops in to 2 meshes (one for the left side of the road and one on the right). Draw calls and batching are now roughly the same for my farm tiles as they are for my town tiles (50 & 60) and often less and when testing on the iPad I’m back up to a healthy 55-60fps throughout the farm section.

Oh and this is what the new tiles look like in-game too.


Leave a Reply

Your email address will not be published. Required fields are marked *