- Home /
Create Grid and Snap Rigidbodies to Grid
I'm not much of a programmer and I'm having a difficult time with the following:
Setting up a grid system
Snapping objects with the dragrigidbody script to the grid once the mouse button is released.
Any examples or pointers would be much appreciated!
Answer by Berenger · Jan 12, 2012 at 05:39 AM
I don't know about that script, but you can probably store all your grids points and once you release the mouse find the closest (and use trees or regions, but if you're not much of a programmer, that might be a stretch).
Oooooor, a probably more clever way would be to have gameObjects on each of your gridPoints with a collider, so you can use Physics.OverlapSphere() and then narrow down your list of candidate for the closest.
As to build the grid itself, you'll need some Vector3, two loops "for" and if you want a visual, LineRenderer.
Have fun !
here you go, I had some free time : http://dl.free.fr/h7eTm4jBO
Your answer
Follow this Question
Related Questions
Grid snapping 0 Answers
Is there a way to check if something was snapped on a specific grid? 1 Answer
cannot get snap to grid to activate 0 Answers
Snap to grid edge midpoints? 1 Answer
Snap to grid not working for me 1 Answer