I'm developing a game for iPhones, which have a body placed in the bottom center of the sreen, and I want to move that body in horizontal axis by player tilting his device in y axis.
Everything okay with that, but I want the body to move in a physical-credible manner.
I have a formula for a velocity of the body:
V[current] = V[previous_step] + acceleration * dt;
I don't understand (totally) a couple of things:
- If user tilt a device, and we have a float value aTiltVector, that changes through -1 to 1, and gives us a magnitude and direction of a tilt, should I add this vector at beginning as an acceleration, or startup velocity? Should I add this value to the velocity of the body or its acceleration?
- How should my body stop? If we give an initial velocity and acceleration, how should it stop if no other force is impacting our body? It would roll down to the edge of the screen then.
- How do you typically achieve that behavior?