So i’m looking for some input to see if i’m going about this the most efficient way. I created some code that would spawn a grid of objects, I tried this with cubes,planes and emptys each with the renderer.enabled = false
. I am trying to create a grid for building placement.
The intial attempt I set the size to 5x5 and spawned them to fill the entire terrain which was 512x512. It was roughly 1000 objects I left a slight margin around the edge of the terrain. There was a slight delay on startup around 5 seconds. I thought of creating a prefab with the grid rather than instantiating it, but unity would just freeze up any time I tried to move that many objects into a prefab.
Second attempt I created a larger grid with empty objects with a box collider attached, this was pritty much instant and I added that to a prefab and left it in the scene. Then created a smaller grid of 0.5 x 0.5 squares with a 10x10 grid that I would instanciate if a certain boolean was true and the players mouse was in that section of the grid and then destroy it. The smaller grid had a renderer on it but would only enabled if the player was placing a building over that tile.
So my questions …
Is there a better way todo it ?
Should I just instantiate everything and add some sort of loading screen?
I had some strange results with changing the size of the box collider and the scale. Should I just change the scale and leave the collider at the default ?
Is there an easy way to make the grid follow the height of the terrain, maybe apply something like a height map to it ?
The function that called the instantiate on the grid would happen if the raycast hit a tag which was the “grid”, the smaller grid would rather than appear in the single section would just spawn a grid in each section. Is this todo with the empty I’m using to hold them ?
A real pain I had is going through and reseting the script so I could actualy chose the object I wanted to instantiate or forgot to set the correct tag on the object. Is there a quick way of reseting/setting multiple scripts/tags on objects ?
Hope this is as clear to everyone else as I think it is
Thanks