- Home /
Moving an Object from Point A to Point B by the Drag Method
I am wanting to be able to select a moveable object for my game that when I select the object I would then drag the mouse to the area where I want the object to move and then click again to begin the objects movement from the rest location to the new location.
What script should I be looking for?
Drag & Drop
Raycast
Get reference
While button down - transform with mouse
On button up, drop reference
If you are going to be using Physics with your object, there is a script that is part of the standard assets that comes with Unity called "DragRigidBody". Use Asset/Import Package/Scripts to get this script. Attached to any game object in the scene. Attach a Rigidbody to any object in the scene you want to drag (may have to turn off gravity if your objects are not resting on something), and then run.
Your answer
Follow this Question
Related Questions
Disable/enable script and animation when you move your mouse cursor 1 Answer
Can someone help me with my TPS Controller/Camera? 1 Answer
Simple Object Dragging 0 Answers
On object click change scene 2 Answers
Click to destroy object 2 Answers