- Home /
Using fewer Game Objects in a Tile-Based Puzzle Game?
I'm working on a matching-tile puzzle game where the player can move tiles, a row at a time - or every row at once. However, the player can also move certain columns of tiles up in certain circumstances. When the user moves a row to the left, the leftmost tile will be moved to the far right, and vice versa when moving to the right.
Right now, each individual tile is its own Game Object with a sprite in it, which means that with a single row movement, 8 GameObjects are being moved (tweening is handled with the DOTween library), and in some instances it's possible for up to 256 tiles/Game Objects to be moving at once.
The game runs at a solid 60fps even when this is happening on all of the computers I've tested it on, but once over 100 Game Objects are being moved at once, this leads to some slowdown in console development, and presumably on slower computers.
Is there a better way of handling this than having a separate Game Object for each tile?
Answer by GiyomuGames · Nov 04, 2015 at 08:32 AM
There is at least one other way which I have personally implemented in my tile base platformer. I used to have 1 sprite / tile but performance-wise it was definitely not optimal. Now I use MeshRenderer to draw each group of tiles (4x10 tiles for example is now just 1 object with 1 mesh).
In your case in the end you could have 1 game object rendering all your tiles as the grid is already defined (let's call it "AllTiles"). You will never have to actually move game objects, just to update the status of your tiles internally and update AllTiles accordingly by telling him which textures to draw at which position of your grid / mesh.
I learnt how to do it with this tutorial: http://studentgamedev.blogspot.jp/2013/08/unity-voxel-tutorial-part-1-generating.html
Thank you! This probably seems like the best way of implementing this sort of thing.
Now I just need to figure out if this is worth the cost - right now I'm using DOTween for animation, and if I went this route it looks like I'd have to write all that tweening and animation logic from scratch.
Your answer
![](https://koobas.hobune.stream/wayback/20220612043839im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Number of scripts per Object. Optimization question. 1 Answer
Distribute terrain in zones 3 Answers
Mesh.CombineMeshes does not work when mergeSubMeshes=false 2 Answers
Multiple Cars not working 1 Answer