Instantiating cubes at runtime, align them

I’m making a little game demo where I’m playing around with some ideas. At the moment I’m allowing my player to build his own house in a way very similar to Minecraft. A cube prefab serves as the building block and the user can use his mouse to instantiate a cube wherever the mouse is pointing.

This works at the moment but it is very hard to get the cubes aligned properly, to make a “smooth” house.

Does anyone have any clues to help me make my blocks “snatch” together (ie: Minecraft building) instead of having them be instantiated exactly where the mouse cursor is pointing.

When instantiating, round the numbers. Untested but it should work.

Vector3 objectPos = Camera.current.ScreenToWorldPoint((int)mousePos);

Instantiate(yourObject, objectPos, Quaternion.identity);