- Home /
Building System Help
Hello I am trying to create a building system where the user can drag the blocks into place right now I only have a GUI that instantates a block puts it in the selected varible and then you can edit the x,y,and z axis with other GUI buttons. Is there a way to tell what someone clicked and store it in a varible and is there a way to drag blocks.
You have a couple of options. You can add scripts to each of the blocks and use On$$anonymous$$ouseDown(), On$$anonymous$$ouseDrag() and On$$anonymous$$ouseUp(). The blocks would then move themselves. Or you can use Raycasting to find and move your blocks and move them from "outside." The On$$anonymous$$ouse* routines are a bit simpler. Raycasting is a bit more flexible. If you Google UnityAnsers, you will find 1000's of hits for "Drag Drop" and 10,000's of hits for "Raycast". There are many answers (many with scripts or code fragments), on this list.
You may have an additional complication with your code. A mouse (or a finger) is a 2D device, and building blocks can be a 3D activity.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Footstep Script Not Working 2 Answers
TERA style movement 1 Answer