- Home /
I am having a problem with momentum of an object after releasing a touch from the iPhone.
I am at an impasse. I can touch an object with my finger and it will follow the movement. What I then want is for the object to continue in a decaying arch once I have picked up my finger. I have all of my touch controls in the FinalUpdate function. Any help would be appreciated.
Answer by StephanK · Mar 19, 2010 at 09:43 AM
If your object is a rigidbody you could add a force to it that is proportional to your finger's movement speed before you release the object.
If it's not a rigidbody you could implement a kind of smoothing for the acceleration of the object. On release start a coroutine that interpolates you movement speed between last known speed and 0 over a given time.
I think there could be a better method to this problem. I have a ray going from the mainCamera to the object and I have noticed that this ray will point in the direction that I want. So I can take the ray's direction and notice that the x value is negative then throw left. If the ray's direction has a x value of positive, the I know it should throw right.
Answer by crevelop · Jun 21, 2011 at 01:09 AM
This tutorial has an interesting inertia code after dragging and rotating an object, you might find it useful.
http://www.youtube.com/watch?v=oOfPMKdJdKk
source code is here:
http://www.revelopment.co.uk/tutorials/unitytutorials/73-howtorotateanobjectbytouch
Your answer
Follow this Question
Related Questions
Infinite swing with SpringJoint 2 Answers
Block UnityGUI Hit 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Strange Rigidbody Behavior 0 Answers
Changing Rigidbody drag on the fly 1 Answer