When I first started trying to set up my air units' movement in my RTS game, I thought it was going to be easy with simple Euler method linear acceleration. This was far from the case as the ship would have to slow to a halt on exactly the target destination, as well as properly compensate after a sharp turn.

How would I decelerate my unit exactly onto the target destination and properly compensate for changed destinations while still factoring in the current velocity in a 2D simulation (Positions and velocity stored in 2D vectors)?

StarCraft 2 does this well, and I'd like to arrive at a similar effect. I want something like shown here. Acceleration can be seen at 0:20. Turning and maintaining momentum can be seen at 1:25. Deceleration can be seen at 1:55. (Find these times in recent comments of the video).

Note: I'm using a lockstep model and frame rate can be either 5 or 10 per second depending on players' computer abilities.

  • \$\begingroup\$ Given a speed and a deceleration you should be able to find the stopping distance, and fudge the last few frames to make it exact \$\endgroup\$ Commented Jan 9, 2015 at 8:24
  • \$\begingroup\$ I've been using (n * (n-1)) / 2 * Velocity.magnitude for the stopping distance and interpolating the velocity vector down to 0,0 over the length of n frames (based on acceleration). This works pretty well if the ship is going in a straight line and accelerating directly towards the destination but overshoots when a turn happens. I think dealing with turning is my biggest issue. \$\endgroup\$
    – JPtheK9
    Commented Jan 9, 2015 at 8:40
  • \$\begingroup\$ As I know starcraft 2 steering don't deal with turning (and I don't know RTS that does it). Unit moves to any direction without rotation. And when unit has new velocity it rotates to this direction through few frames with some heuristic (for example, divide angle between current direction and target direction by 2). \$\endgroup\$ Commented Jan 9, 2015 at 9:30
  • \$\begingroup\$ If you are dealing with rotation, you need to define an angular rotation speed and then use something like this: gamedev.stackexchange.com/questions/73046/… \$\endgroup\$
    – AturSams
    Commented Jan 9, 2015 at 10:17
  • \$\begingroup\$ I've always found this website a good source for steering behaviours, in your case: red3d.com/cwr/steer/Arrival.html the full paper is available at red3d.com/cwr/papers/1999/gdc99steer.pdf \$\endgroup\$ Commented Jan 9, 2015 at 11:40

1 Answer 1


I found the answer thanks to this essay Daniel posted. It's something like this (from page 10):

closing_distance = max_speed * 2;
desired_velocity = normalize (position - target) * max_speed
if (distance < closing_distance)
    desired_velocity *= (distance / closing_distance);
steering = desired_velocity - velocity

You must log in to answer this question.

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