- Home /
How to Touch Drag 3D Objects
New to Unity and Scripting... I would like a simple example of dragging a 3D object by touching the screen. I would like the object to stay under the users finger when moving. I am either terrible at searching or there aren't many simple examples out there (probably the former).
(I would then like to restrict the drag movement to the xz plane but I will add this as a separate question.)
Answer by DaveA · Oct 24, 2011 at 08:36 PM
See http://unity3d.com/support/documentation/ScriptReference/Collider.Raycast.html. You would implement an OnMouseDrag handler in a script to set the position. To keep it in xz, just set the y component to 0 (or whatever constant you want).
Answer by LostInCode404 · Jun 29, 2014 at 09:17 AM
I've made a tutorial recently for touch and drag objects in unity on my blog. See if it helps you in solving your problem. Link - newtonians3d.blogspot.com/2014/06/a-simple-and-efficient-touch-and-drag.html
Your answer
Follow this Question
Related Questions
How to drag object along with dragging touch? 1 Answer
Help with iphone/android touch controls 2 Answers
How Can I Drag the Object With Touch ? (Mobile) 4 Answers
How to make a character move towards a side of the screen that's pressed at a constant rate? 2 Answers
I Need Help With Mobile Touch Movement. 0 Answers