- Home /
Grid Based Mouse Drag
I am making a sort of puzzle game in which the player slides cubes around a grid. But I can't seem to be able to come up with, or find a way, to allow a mouse drag to move the cubes. Basically, I want to be able to click on the cube, and then drag in the direction that I want it to move. I can move a cube with something like the arrow keys, but I just can't get it to move from a mouse drag.
Thanks in advance!
Answer by GesterX · May 16, 2011 at 06:32 PM
The script HERE will do what you want. You're going to have to extend it if you want to restrict movement to a grid but this should be a good starting point.
After modifying the script a little, as you said, I have got a working mouse drag! Thanks +1
The link is not working anymore, this one HERE does (the domain is changed to wiki.unity3d.com)
Your answer
![](https://koobas.hobune.stream/wayback/20220613134458im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Where do i put this script??? 4 Answers
Why pixel artifacts on aligned cubes? 1 Answer
how can i drag na cube while gameplay? 1 Answer
Tracking ojects grid positon 1 Answer
Snap blocks that aren't cubes. 1 Answer