Physics based character movment

Started by
1 comment, last by Kaze 14 years, 5 months ago
Does anyone have a sample algorithm or tutorial for how much force to apply to a physics body in one axis to make it move given a desired velocity along said axis and a maximum force to apply to achieve said velocity. Its for a 2d platformer and I set all the friction to zero so the characters will behave the same in mid air or on the ground.
Advertisement
float desiredVelocity, currentVelocity;
const float timeStep = 0.1f;

float deltaV = desiredVelocity - currentVelocity;
float impulse = deltaV * mass;
float force = impulse / timeStep;
Thanks, that worked ok

This topic is closed to new replies.

Advertisement