Drag n Drop Cube To Snap In Place - Grid

Hello,

I have a cube on my scene that has the Drag Rigidbody, so I can move it around the scene with the mouse. On the floor of my scene is a grid (which is just a material). It is possible to make the cube snap into the grid when the user lets go of the cube (A drag n drop snap).

Here is a screen shot of my scene normally: http://olliejones.com/gridsnap.png

I was thinking that maybe by placing Empties within each grid, will return the empties position value in which the cube could snap to ... surely?

Or is there a way to have the grid interactive - instead of using a material, Unity actually places a mathematical grid down...

Thanks

You will have to write a special handle for the mouse events.

Maybe something like this can help in pseudo-mush.

if (mouse dragged right) { increment object location with distance of one tile to absolute right }

if (mouse dragged left) { increment object location with distance of one tile to absolute left }

absolute values will cause great suffering though if you rotate the grid of course. So do relative values instead if you plan on changing the grid/tile design

I don't have the option to write you a whole sample now so I hope I can get the idea through quickly enough whilst rushing this text.

Good luck and regards!