I am working on a game based around Newtonian physics. Therefore there is no drag and therefore a ship will keep accelerating indefinitely if there is no counter-force acting on it. This is being built within Unreal Engine and it is entirely based on physics thrusters (i.e. "Add Force at Location").

For gameplay purposes I'd like to implement a "speed limit". Consider a simple seek steering behaviour. Ship A is pursuing Ship B. Ship A reaches the "speed limit" at time t0. Ship B changes direction at time t1.

If I calculate the new direction at t1, and then "cap" the speed at time t1 + 1 frame, Ship A will continue on its original direction, because accelerating towards another direction would make its total linear velocity greater than the speed limit.

If instead of calculating the "global" instantaneous velocity I only calculate the projection of the velocity vector along its forward axis, then it works.

However, there are some fringe cases. For example if the new direction is almost orthogonal to the velocity vector, then that means that its projection on the forward axis will be very small in magnitude. The ship will thus reach speeds well above the limit, only to have a "hard brake" when the velocity projection reaches the limit on its forward axis.

Which other methods could I use to limit speed? I thought about removing a software-based limit altogether and just make sure that the ship is braking whenever it is close to the limit. While more realistic, I'm afraid it might look less interesting.

  • \$\begingroup\$ "Using Newtonian physics" and "therefore there is no drag" makes no sense. Newtonian physics fully explains drag. With relativistic physics, objects' mass increases with speed, and reaches infinity at the speed of light, hence requiring an infinite amount of force to accelerate it. That's not drag, that's relativity. \$\endgroup\$
    – Almo
    Jul 6 '18 at 13:08

Myself, I like to use an AccelerateTowards method that takes a target velocity and a maximum acceleration (though the same thing can be done with forces by incorporating mass):

targetVelocity = inputVector * maxSpeed

// If inputVector has length <= 1 
// then this obeys our speed limit by construction.

// Compute the change needed to reach the target.
deltaV = targetVelocity - currentVelocity
accel = deltaV/dT

// Clamp to what our engines can do.
// maxAcceleration = maxForce / mass
if (accel.length > maxAcceleration)
    accel = Normalize(accel) * maxAcceleration

force = accel * mass

This will let you put your full allowed force into changing direction even if you're already travelling at the speed limit, and will enforce the speed limit throughout the turn (so you don't travel faster diagonally in-between)


Depending on how 'arcady' your game should be, this might be difficult.

In real life, if you have high velocities, the energy needed to accelerate further is increasing by the square. So doubling your velocity would mean quadruple the energy needed. A realistic approach to that problem could be, that your engines cant provide enough thrust to accelerate much further. So your acceleration flattens out, while you still get faster and faster, as your acceleration never reaches zero.

Now you could 'science-babble' your way out of it:

  • Your engines need a certain acceleration, cause of plasma fields, so limiting speed to a certain point where acceleration would still be enough.
  • Stuctural integrity: as a safety measure your speed is capped. If you would accelerate further, every slight deviation from your flight vector would damage and/or destroy your ship/engine/pilot. (And a perfect linear acceleration vector is impossible)
  • Galactic Rulings: Flying with higher speeds may disrupt the subspace the engines are using to accelerate (power them or as something to push from).

The second point would in my oppinion fit best with your orthogonal example. If a pilot tries something like accelerating orthogonal to its original vector, damage the ship SLIGHTLY. A player could use it as a risk/reward mechanic, doing sick maneuvers at cost of health or hull.

If you want to make it feel more arcady, just cap it and say thats the limit because reasons. Noone will ask for a reasons and it will fit right in. Just always reduce the maximal velocity to the cap while keeping the new vectors direction


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .