- Home /
Tiles Slow Down Game
I am making a game where there is a huge grid of hexagonal tiles. I've made the tiles into a prefab and do all the generation via script at runtime. The problem is when they are rendered, there is noticeable lag in the UnityEditor and when the game is built. I am running a grid of 256x256 tiles right now and it's causing major lag when they're all rendered. The way the game is setup is that more than just those tiles would be rendered. Would there be a better way to do this? I'd like to keep the tiles because I will need them for selection purposes from the user.
Note: when the user gets closer to the tiles and less are visible, then the game runs fine. However, as previously stated, the game cannot be played like that especially the way the scaling of the tiles are at the moment.
$$anonymous$$aybe look into generating them as a whole mesh as opposed to individual gameobjects.
^What he said. tile system of this magnitude are not meant to be done by seperate gameobjects. Look into procedural mesh generation and don't forget to consult the Scripting API (especially the $$anonymous$$esh class). Selectin tiles etc. can all be done by script as well.
Savion and Cherno, thanks for the input guys. I'll have a look into that. It should be extremely easy for me to change the script to do this into a 256x256 grid on a single mesh. As for selecting individual tiles in this mesh and changing color values, etc. What would you suggest doing to select a single hex inside the mesh of hexagons?
There's a few different coordinate systems you could use to keep track of your hexagons. This site has a great article on it.
cjdev, thanks!! I really enjoyed that page. I'd recommend that too. I'm surprised i never came across that in my google search, I usually find everything that way. Thanks guys.
Your answer
![](https://koobas.hobune.stream/wayback/20220612001059im_/https://answers.unity.com/themes/thub/images/avi.jpg)