I have a 2d scene. I want the player to be able to pick up an object, move it around the scene and drop it somewhere. I can't find any way to do this, and all of the resources for Unity are really daunting and I can't find anything relevant to what I'm doing.

I've tried adding the drag rigidbody script to both my camera and the sprite I want to drag, to no effect.

Where can I find relevant documentation for stuff like this? Basic things like how to implement a script or what objects I need to attach these scripts to - the stuff on the unity website is a little too advanced.


1 Answer 1


Basically you say that the Object follows your mouse coordinates after you clicked it.

Use: if (Input.GetMouseButtonDown(0)){ /*Move Object which gets hit by the Raycast you shoot to Mouse coordinates */};

Also you have to convert the world coordinates to screen coordinates.

Here is a good Tutorial for that: Klick

  • \$\begingroup\$ Do I attach that script to the camera or each object I want to pick up? If it's the camera, how can I make it s.t. only one object can be dragged? \$\endgroup\$
    – Daniel Bak
    Jan 28, 2015 at 15:31
  • \$\begingroup\$ You can attach it to the camera or the a GameManager object. Just shoot a Raycast and check with RaycastHit for example the tag from the object you want to move \$\endgroup\$
    – PM_
    Jan 29, 2015 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .