Jump to content
  • Advertisement
Sign in to follow this  

topdown physics.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, i need to implement top down physics in jBox2D and i need some tips about linear and angular friction.

Recently i was using this equations, which were producing non natural effects.

_needed_velocity = 0;
_needed_velocity = _current_velocity + _acceleration * time_delta;
0 = _current_velocity + _acceleration * time_delta;
(0 - _current_velocity) / time_delta = _acceleration;
_acceleration = (- _current_velocity) / time_delta; //which were producing large large number but it worked.

//this is just an example of my concept non natural concept.

_acceleration = (- _current_velocity) / time_delta;
_Force = _acceleration * _body_mass;

_ForceKineticFriction = 0.525 * _body_mass * 9.81; // kinetic friction
_ForceStaticFriction = 0.900 * _body_mass * 9.81; // static friction

if(_Force.lengthSquared() > _ForceStaticFriction * _ForceStaticFriction)
_Force = _Force.sub(_Force.normalize().mul(_ForceStaticFriction));
/// Means...
/// _Force = _Force - _Force_ForceStaticFriction;


Share this post

Link to post
Share on other sites

Please give us a bit more information. Can you give us an example of the type of effect you are looking to produce? You don't have to describe your game in detail, if you don't want to. I'm just looking for a concrete example that we could use for judging the code. It will help understand what you mean by "non natural effects," for example.

Share this post

Link to post
Share on other sites
I have totally missed that part. :)

Ok, lets start.
I have jBox2D physics engine i would like to use it for topdown. I implemented my own prestep callback which is called before world.step(); in which will update topdown bodies. This is no problem.

In first attempt to add "realistic" topdown friction.

1.If i want to stop body to move the end velocity must be 0(v=0). and v, v0, a are vectors. v0 is current speed, dt is time step. a is body acceleration(which i am looking for)

2.I move around elements assuming v=0

This gives me accleration which is needed to stop body from moving in timestep t.

Force is: (a is acceleration, m is mass of the body)

If i joint these two equations together i get this.
This is force which stops body from moving in current timestep. Which actually is very unnatural.

5. I took friction force in consideration which would make body realistic, but it dont.

6. Friction equations. g is gravity constant.
Static friction. ks is static friction coef.

Kinetic friction. kk is kinetic friction coef

Assume the F_k and F_s are all ready aligned with F;(F_k=(F/|F|*F_k)).

7. I check if F is greater than F_s and if is greater than static friction then i substract F_k from F. else if use F as force.


at the end i apply this F_friction to body at the center of mass.

//this are all equations together.




Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!