x


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.)

more ▼

asked Oct 24 '11 at 08:34 PM

yackbladder gravatar image

yackbladder
1 6 7 7

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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).

more ▼

answered Oct 24 '11 at 08:36 PM

DaveA gravatar image

DaveA
26.5k 151 171 256

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2465
x1367
x1093
x580
x286

asked: Oct 24 '11 at 08:34 PM

Seen: 2561 times

Last Updated: Oct 24 '11 at 08:36 PM