I’m using Box2D through Libgdx to create a scene. I have a scenario where I would like to constantly propel a specific object using applyForce (the direction would change from time to time), but only up to a given speed.
Picture a circular object propelled by a rocket motor (with nozzles on all sides), in zero G, for illustration.
Is there a way to do this without recalculating the force applied, or performing a repeated calculation each update? I only know how to set a maximum speed for all objects. My best bet at the moment is to use linearDamping somehow, but I’m hoping there’s a simpler solution.
You could override the current velocity with SetLinearVelocity.
===============
EDIT:
Simple air resistance can be modeled by applying a small drag force in the opposite direction of travel, scaled with the speed of travel.
The scale value for the drag (0.05 in this example) determines the speed at which the drag force will equal the force applied by the rocket motor and the two forces cancel each other, giving a top speed.
Purists will point out that drag is actually relative to the square of the velocity, so to be more accurate you could do:
… which I think would give you a top speed of