Question about making a grid-based building game with empty gameobjects

Hello Unity forums,
I have a quick question. I’m new to this type of programming and I’m having trouble visualizing and coming up with smart ways of doing things.
I want to have a grid that the user sees top-down. On the side, they select a type of block, and tap on the grid to place that block. Very similar to “Minecraft” in style.

My idea of how to do this is to have a 100x100 grid of empty gameobjects. Each gameobject represents the center of one block. When the player taps the gameobject, it changes itself to the prefab for the current block to be placed. Each block prefab has the same script, so when the empty gameobject is changed, it can be changed to other blocks or to an empty tile again.

Is this a smart way of doing it? Do each of those 1000 gameobjects have a draw call? If it’s an empty gameobject (only containing a script) is it even possible for it to recognize an input from the player?

Sorry if this is rambling or illogical. Like I said I’m very new to this.
Thanks for reading.

Oh yeah, just in case it’s important, this is for a mobile game. So I really need good optimization.

That is a way of doing it, but especially for mobile it will be wasteful of memory. You will have 10,000 objects that aren’t really necessary, taking up memory, and then have to be garbage collected once they are destroyed.

Instead, put a script on your terrain/map, and use the OnMouse events, and look at the X/Y coordinates, divide appropriately to see what grid coordinate was clicked. Then place the prefab building down in the center of that grid.

Thanks, that makes way more sense. I appreciate your help.
I’ll probably be back later with a thousand more questions! :slight_smile: