Steering behaviors: Path Following 

I’m studying the so called “steering behaviours” described by the paper writen by Craig W. Reynolds. Another good resource for more on this subject are the serie of posts found in very nice examples and pseudo code. Without to mention the awesome Java Applets found here:


This behaviours are aimed to simulate inteligent movement of moving objects. Starting from one simple -mother of all- behaviour (“seek”), you can stack several or one into an objects moving pattern and the resulting product will look like if the object had some kind of decition making behind it’s movement. What you basically do is to apply forces to an object’s velocity, with the intention of “steer” from or to a specific point in space. At it’s core, regardles of how complicated the calculations get, the resulting product is a force vector that one should apply to one or more objects.


The most basic behaviour it’s called “Seek“, which makes the object seems like if it were following a target. You always work with vector operations.

Steps to apply the seek behaviour to an object (pseudo code, assume a Vector class available):

  1. Calculate the desired velocity = Vector(target.positionVector – vehicle.positionVector).normalize().multiply( vehicleMaximalSpeed );
  2. Calculate seek steering (the force used to make the vehicle steer) = Vector( desiredVelocityVector – vehicleVelocityVector )
  3. Add this vector to the current speed: CurrentSpeedVector.add( seekSteeringVector )

Now you just move the object: object.position += velocityVector. This si the basic stuff. As an extra, you can for example, scale the steering force based on some factors, like, the mass of the object, or the distance from the target to the vehicle, etc… but the basics are done in thouse 3 steps. In every other steer behaviour, the calculations will turn arround finding an imaginary ideal position for the vehicle and then, make the vehicle seek that position.



Here what you basically do is to create a path, find the closest point form the “vehicle’s position in the future” to the path, and check if the distance from that point to the vehicle is greater than some distance you decide. If it is, then that means that the vehicle will eventually leave the path’s segment in which currently is, so we “seek” the vehicle to the farthest point in that future offset to the path. In the image below, that point would be the closest point in the red lines to the path.

So you basically calculate this imaginary point and then, back to the “Seek” behaviour. So you work here with two behaviours one on top of the other. Being the “path following above” and the “seek” bellow (in order of execution).

Only let the vehicle get X far form the path, if it goes beyong, then seek to the fartest point allowed.

I attempted to implement this in flash / actionscript 3 (my weapon of choise) and this is what i got (you need Flash player 10)

My implementation in flash (just for learning):

This is one made in java by someone else:

That’s it, more to come.