- Home /
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
Answer by DavidDebnar · Jul 09, 2011 at 07:07 AM
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
Your answer
Follow this Question
Related Questions
Make A Cube 'Sticky' 4 Answers
Lego-building System. 1 Answer
Cube moving through rigid body 2 Answers
Make a rolling ball always on ground without falling when reaching the edges of the map 1 Answer