# Help with simple physics update!!

This topic is 3893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm working on a platform game with some people in a class, and I'm having a problem with my physics class update. First of all, here is the physics code:
acceleration = force + gravity + (velocity * dragCoefficient);
velocity = velocity + acceleration * dt;
position = position + velocity * dt;
force = force * frictionCoefficient;

dt is deltaTime and is in seconds. obviously it's a very very small number. acceleration, force, gravity, velocity, and position are all vectors (2D vectors with only an X and Y). I know that "frictionCoefficient" isn't the correct term for this, but i needed a way to slow the player down, and change their friction on icy terrain. I have some frictions #defined, such as #define FRICTION_AIR 0.998 and #define FRICTION_GRASS 0.6 Right now i have gravity set to Vector2D(0.0f, 100.0f). Yes, I know that 9.81 is proper. The real problem I'm having is that jump won't always work. And in order to get it to work I have to set force to -4000 in the Y. otherwise i just stay stuck. SO....yes...I know this is a bit scattered. If you need ANY info i'm not giving then let me know please. Basically I know there is something wrong with my physics update but i'm not sure what it is. I need to apply an initial force that makes more sense to make the character jump. -4000 is a bit much. in order to walk i'm currently doing force.x += 25 (for right...-= 25 for left) Please help..and thanks in advance!

##### Share on other sites
It seems like you wouldn't want to change the force every time through.
For jumping, you want to model a projectile - but a projectile only has an initial force...after that, the only force acting on the object is gravity and wind resistance.
For walking, the person would always be exerting the same force, trying to move. Friction would act against that force, and the velocity should be calculated from that (although the velocity should be maximized).

Remember from physics class:
velocity = delta(position) / delta(time)
acceleration = delta(velocity) / delta(time)
force = mass * acceleration

Hope something here helps...

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633302
• Total Posts
3011272
• ### Who's Online (See full list)

There are no registered users currently online

×