- Home /
Drag / Snap To Grid square / building
Okay,
I am trying to create a "Room Builder" sort of thing and need assistance.
I would like to create a grid on a terrain that you can then select one area and Drag it across which will make a square.
Like the sims house creation system where you select the wall and a point and then drag and it will create a square if you will.
Thanks
Comment
To snap a Vector3 to a grid (1x1x1 in this case), use $$anonymous$$athf.RoundToInt or $$anonymous$$athf.FloorToInt, depending on how you want the snapping to behave.
Vector3 pos_snapped = new Vector3($$anonymous$$athf.RoundToInt(pos.x),$$anonymous$$athf.RoundToInt(pos.y),$$anonymous$$athf.RoundToInt(pos.z));
Vector3 pos_snapped = new Vector3($$anonymous$$athf.FloorToInt(pos.x),$$anonymous$$athf.FloorToInt(pos.y),$$anonymous$$athf.FloorToInt(pos.z));
Your answer
![](https://koobas.hobune.stream/wayback/20220612133353im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Leaks between planes with different material 2 Answers
Snap Terrain to Building/Structure 0 Answers
How to snap objects in game 2 Answers
Create Building Level like Sims 1 Answer