- Home /
Drag and throw Rigidbody2d?
How would I go about dragging and throwing a 2d rigidbody with the mouse?
As a staring point, play with the standard DragRigidbody.js script:
Assets > Import Package > Scripts
I have played around, but I will see what more I can do :) thanks
Answer by EBR · Feb 15, 2014 at 06:32 PM
Answering my own question :P I dug around and found this, exactly what I was going to do. Perfect for what I need. Hope this helps anyone else who was looking
Hi, what did you exactly do to implement this script ?
It is identical to the dragrigidbody script but for the 2d physics system. If you have 2d physics objects set up you just add the script to, for example the camera and it should work :)
Answer by Anxo · Feb 15, 2014 at 05:37 PM
Look up "Input" in the scripting docs. Then you will be able to cast a ray from the mouse position that will allow you to select drag and flick an object
Answer by Rapskalian · Jun 19, 2014 at 12:46 AM
You can also check out DragRigidbody2D on the asset store. It's just one script attached to the camera and works right out of the box on all platforms. DragRigidbody2D