Hi there
I'm trying to implement 2d tiled isometric game
so for box2D it is top-down-view-style
Im not good at physics, but im trying to make it anyways...
Now I need your help
World is 0,0 gravity, objects have damping to prevent them from floating.
Damping fits for a car that was just pushed foward...
to prevent it from moving to the left/right (car should only move foward/backward)
i made this code:
It is Java code for jbox2d. (still should fit box2d)
It works good enough (it is run before every world step).
But now for brakes... adjusting damping is not good for brakes - as damping is multiplying speed - so the slower you drive, the weaker brake is. that is not how brakes work. it should be rather something like friction - but i dont know how to implement that.
Could anyone suggest me some method for realistic brakes?
Or aybe even someone could try to make better overall car physics example.
Regards, Kerai
I'm trying to implement 2d tiled isometric game
so for box2D it is top-down-view-style
Im not good at physics, but im trying to make it anyways...
Now I need your help
World is 0,0 gravity, objects have damping to prevent them from floating.
Damping fits for a car that was just pushed foward...
to prevent it from moving to the left/right (car should only move foward/backward)
i made this code:
Code:
Vec2 vel = car.getLinearVelocity();
vel = car.getLocalVector(vel);
vel.x *= -.5f;
vel.y = 0;
vel = car.getWorldDirection(vel);
car.applyImpulse(vel, car.getWorldCenter());
vel = car.getLocalVector(vel);
vel.x *= -.5f;
vel.y = 0;
vel = car.getWorldDirection(vel);
car.applyImpulse(vel, car.getWorldCenter());
It is Java code for jbox2d. (still should fit box2d)
It works good enough (it is run before every world step).
But now for brakes... adjusting damping is not good for brakes - as damping is multiplying speed - so the slower you drive, the weaker brake is. that is not how brakes work. it should be rather something like friction - but i dont know how to implement that.
Could anyone suggest me some method for realistic brakes?
Or aybe even someone could try to make better overall car physics example.
Regards, Kerai