2d minecraft survival game

I am trying to make a 2d minecraft like survival game as a hobby. I am having a problem getting a grid and level generation to work. I have block selection, A flat level generation, a way to place blocks but not break them, and that’s all I have so far.

If you see the blocks are not placed in a grid instead they are everywhere:
23277-2b64f8b487d1e0de99750a26fa74c495.png

Do you guys know how I can get a grid going and how I can get it to delete blocks. So far blocks are placed at my mouse position using a raycast. All help is appreciated!

You can create a “grid” by rounding the value where you place your block. For instance:

if Physics.Raycast(ray, hit):
go.transform.position = hit.point
go.transform.position = Vector3(Mathf.Round(go.transform.position.x),Mathf.Round(go.transform.position.y),Mathf.Round(go.transform.position.z))

ps: yep, I’m using boo, don’t judge me.