Making 3D Objects Stick On Other Objects Like A Grid?

Hello again Unity Answers!

You guys are a great community, and once again I have a question. I would like to create a building-game of some sort where you can put blocks and stick them on to each other just like a lego. If you have ever played Minecraft, I want to achieve a similiar effect. What I have is raycasting and instantiating. All I need now is to now how to make it stick to the face it's on and/or snap on to a grid.

Hopefully you guys can come through and help me :D

Thanks, Flipbee9

block.position.x = Mathf.Round(actualBlock.position.x);
block.position.y = Mathf.Round(actualBlock.position.y);
block.position.z = Mathf.Round(actualBlock.position.z / 1) * 1;

Edit the 1 and add it to the others, if your blocks scale isn’t 1.

– David

already been done