in-game grid made of GameObjects


I have a question about the best practice for an idea. I’m in the need of a grid during game play. I was thinking of building a grid of GameObjects the width of the game zone. The size will vary depending on the current map.

The GameObjects don’t necessarily need to have their Mesh Renders enabled. Would this help in Frames?

A Ray will detect hits on the grid and instantiate a prefab to that GameObjects position. The method will work for my needs but I get the feeling it will cost a lot in terms of Frames per second. Or will the Mesh Render being disabled help in that?

If it does then my second thought is the number of Box Colliders in the game world. Not including other GameObjects to make up the scene and GameObjects the player creates. It seems expensive on ol’FPS counter.

A good idea or a bad one? Should I work on another way of building a grid?


You haven’t really said why you need a grid of objects. If you just want to raycast against a collider you can simply use one large box collider without any renderer. You also haven’t said how large your grid should be. If you just need it for placement / raycasting it’s probably simpler to use Unity’s Plane struct which represents an infinite mathematical plane which you can raycast against. This wouldn’t mess with the physics system at all. If you want the positions to be in a fix grid it’s just a matter of rounding the coordinates accordingly.