- Home /
Creating tile grid overlays on area (terrain or possibly other objects)
I have checked out some of the current answers but none seem to have a solid answer, they all seem to make some concessions or hack around things to get it working.
Now off the bat I am pretty sure that I will be making each (tile) as a game object, maybe a prefab or something as I will need to interact with it and have some sort of effect to imply it is being interacted with. Then some sort of callback handler for the interactions, however lets put that to one side for the moment, the main point of this block was to show that just having a texture overlay is not what I am after.
I think I have the overall idea of what I need to do, I just dont know that much about terrains in this example, so could do with someone steering me in the right direction.
So I am assuming I will need to get the terrain width/height and multiply it by the size of each tile/chunk in there, or at use some other mechanism, but eventually get the dimensions of the terrain. Then get the size of the tiles being used, and then basically generate a grid of objects in a uniform manner. Now that seems like it should be simple enough, however in the case of slopes and holes is there a way to get the overall normal or angle of slope so I can rotate the tiles in the same sort of way?
Hopefully that all makes sense and someone can chime in with the info I am missing or point me in the right direction.
-- Update --
I have made a simple grid creation editor and script, to create grids and overlay them on whatever is beneath them. However the editor seems to lock up if I do anything major like a grid 200x200 in size (as this would result in 40,000 prefabs created in the scene).
So now the question becomes more how can I handle such large grids in unity without it falling over? I expect I can do something along the lines of limiting it to the screen size and just offsetting it but not sure if anyone has any better ideas or best practices with this? As ideally I want to do sort of build spots in the world, but technically I only need a certain area around the mouse I guess... but I want the tiles in the grid to snap so even if the camera changes the tiles will still be over the same position if that makes sense.