I have a ship with a single thruster in space (no friction). My ship uses integration on every update, like this:
(PSEUDO CODE)
Update() {
Velocity += Acceleration
Velocity = Min(Velocity, MaxSpeed)
Position += Velocity
Acceleration = 0
}
Any force that interacts with the ship will accelerate it:
Accelerate(f) {
f /= Mass
Acceleration += f
}
Finally this is how I thrust the ship:
Thrust() {
f = MaxThrustPower * Angle (cos/sin)
Accelerate(f)
}
Like this I can accelerate my ship thrusting until MaxSpeed is reached.
The problem is that I also accelerate the ship with other forces line Gravity pulls, collisions, friction fields, etc. And all those forces, as they also add to velocity, they are also being truncated by the MaxSpeed limit.
At the other hand, once I have reached MaxSpeed, I cannot thrust any more to change my direction.
(This is a 2D game, not an exact simulator)
How can this be handled properly?
Thanks!