- Home /
Drag-and-Drop GameObjects
Hello, I am looking for a way to drag and drop GameObjects around the screen using the screen touch on the iPhone / iPod Touch / iPad. Currently, I am using a GUI Button to instantiate the object into the world, and now I would like the player to be able to drag each object around by pressing on top of it, and then sliding their finger on the screen. Can you please point me in the right direction?
Thanks
Hi am too struggling here. i need to do the same what you actually asked here. player should able to drag on image, and then sliding by finger, and need to place a 3d object in screen.
if you done with your work, can you help or show me right way to do this?
Answer by crevelop · Aug 18, 2011 at 10:38 PM
I've made few tutorials on dragging and rotating an object by touch(Unity iOS), just wanna share them.
These are the Youtube videos:
Dragging http://youtu.be/QjUhQ4z6pF0
Rotating http://youtu.be/oOfPMKdJdKk
Get the source code from my website:
Hope it helps.
Answer by Murcho · Jun 04, 2010 at 03:32 AM
There's a good script on the wiki to just that. Should at least give you a good research starting point. Script link here.
Note this is for use with a mouse, however converting to use iPhone input shouldn't be too difficult.
@persijn use search engines http://wiki.unity3d.com/index.php/DragObject
Answer by Philip 1 · Jun 04, 2010 at 03:43 AM
I thought you may create one position when you click on the screen then using camera position and "finger" position to made a raycast
this raycast will trigger the object you want to drag when you leave finger away ,the gameobject will be dropped as soon as the raycasthit function ended
now the drag function using fixupdate() to adjust the coordinator of the gameobject by detecting the coordinator of your finger
last but not least,when you try to drag those things with physics effect please add rigibody and collision on that gameobject too
Answer by spk · Aug 08, 2012 at 11:16 PM
FingerGestures has a bunch of toolbox scripts (TBInputManager + TBDrag) to take care of object-dragging for you. You may want to give it a look!
Answer by Aarlangdi · Nov 27, 2013 at 06:25 AM
Check this out this might help you guys -- http://aarlangdi.blogspot.com.au
Your answer
Follow this Question
Related Questions
How to get TouchPosition ?? 1 Answer
Touch Drag GameObject Found 1 Answer
Continuous shooting by holding iPhone button 2 Answers
Inaccuracy in iPhone touch? 0 Answers
Touch To Move iPhone 3 Answers