|
i'm trying to write a script that will allow me to touch an object on the screen of an iPhone and drag it around and when i release it the object stays where i left it, similar to the fruit ninja game (if anyone has played that). i understand the controls for transforming position of an object using the keyboard but am at a loss as to how i can touch an object and keep the object centre as the touch position. any ideas / suggestions? i've been experimenting with this method (for mouse first) that i learned on answers earlier
(comments are locked)
|
|
update: i forgot to post this, it might be useful. i've been experimenting with this method (for mouse first) that i learned on answers earlier Please delete this post. I have made this go into the above.
Jun 16 '11 at 06:40 PM
fireDude67
(comments are locked)
|
|
For touchscreen stuff, you'll be wanting to use Touch events. Essentially, you can replace all your references to mousePosition with the appropriate touch events. It contains the same mouseDown/mouseUp kind of events as you're used to, but they're contained in TouchPhase.
(comments are locked)
|
|
I'd advice checking out the DragRigidbody script that's included in Unity (if you don't have it in your assets folder, import it). It works perfectly and could serve as a good example for you.
(comments are locked)
|

Welcome to UA! Please either edit your original question or post additional details in the comments on your post and not in the answers section.
Yes, please do! I have used my Administrative power and merged the two together, but I cannot delete the answer you have posted.