I'm trying to make a game with physics and hitting up against a problem.
I need to have rocket engines that will only go so fast, BUT the ship should be able to go faster if an external force makes it.
So the rocket engine has a top speed of 100 pixels-per-second and the player could never exceed it, unless for instance the player is being pulled towards a black-hole.
Chipmunk physics has a top speed option but it will also effect external forces.
Is there a way to do this? Or maybe is there a formula for reducing thrust based on speed and angle of motion?
Develop games in your browser. Powerful, performant & highly capable.
You would need to project the current velocity vector onto the direction vector of the thrust:
And measure whether the projected vector is lower than the maximum velocity allowed. If it is lower, then it would be okay t add thrust in that direction.