Skip to main content
GameDev.net gamedev.net
🔒 Locked

Physics based character movment

Started by Kaze Nov 25, 2009 at 4:47 PM 1 replies 1k views
Original Post
Kaze
Kaze
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.
bzroom
bzroom
float desiredVelocity, currentVelocity;
const float timeStep = 0.1f;

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.