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?
I’ve made few tutorials on dragging and rotating an object by touch(Unity iOS), just wanna share them.
These are the Youtube videos:
Get the source code from my website:
Hope it helps.
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.
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
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!
Check this out this might help you guys – http://aarlangdi.blogspot.com.au