technique

Seek steering behavior

An agent rotates its heading a fixed amount per frame toward the angle to a target point (nearest neighbor or the mouse), then moves forward along that heading.

Also called: Seek steering (turn-toward-target) · angle-based seek · turn-toward-target steering · seek · flee

What it is

Seek points an agent at a target and moves it toward that point. Two different implementations sit under this one entity in the corpus, and they use genuinely different mechanics. Nature of Code names its version “the seek steering force algorithm” — the same chapter is where the alias “seek” comes from. Happy Coding’s code is evidenced here only as two isolated comments rather than a written-out algorithm: one turns an object toward the mouse, one guards a heading-to-target angle calculation against wraparound. What follows keeps the two apart rather than blending them.

How it works

Happy Coding’s heading-turn version. The evidence is two code comments, so that is what this section can say:

Nature of Code’s force-based version. The one step given directly by the excerpts: compute a desired velocity, “a vector that points from its current position to the target position.” What happens to that desired velocity next is the general steering force mechanic — for that entity, described as subtracting the agent’s current velocity from its desired velocity to get the correcting force. The same chapter separately invokes Newton’s second law, adding, in its own words, that it “skip[s] the math” — the excerpts don’t say where that fits in the sequence, so this page won’t guess at one.

Parameters & tuning

No tunable parameter — turn rate, speed, force limit, anything numeric — appears in the evidence gathered for either version. What the record does establish is a shared failure mode: Arrive is described as decelerating smoothly inside a slowing radius instead of overshooting the target, which only makes sense if plain seek overshoots on its own. That overshoot is the corpus’s stated reason Arrive exists as its own entity rather than a setting on this one.

Where it’s been used

Both mechanics are evidenced here only as tutorial code, not as named artworks. Happy Coding’s mouse-follow sketch and its wraparound-guarded heading sketch are two separate pieces of code from the same source. Nature of Code presents its own version under the heading “the seek steering force algorithm,” in a chapter the corpus’s license notes list as “Autonomous Agents.”

Variants & neighbours

Arrive is the same idea with a slowing radius added: it decelerates smoothly inside that radius instead of overshooting, which is the failure mode noted above. Wander keeps seek’s own machinery but moves the target itself — a point drifting randomly around the perimeter of a circle projected ahead of the vehicle, keeping the result directionally ordered rather than fully random. Path following contrasts by not seeking a fixed point at all: it predicts a future position, finds the nearest point on a path, and seeks a target only a little ahead of that point, and only once the vehicle has strayed too far. Flocking is described as every agent running the same closest-neighbour turn at once, by a fixed angle increment, producing the flock’s emergent swirl.

Go deeper

Nature of Code’s Autonomous Agents chapter, read directly, for the force-based version. Happy Coding’s two sketches: the mouse-follow one and the wraparound-guarded one.

Connected to

Variant of: Arrive steering behavior

Contrast with: Wander steering behavior · Path following

A kind of: Steering force

Built from: Steering force

Variants: Arrive steering behavior · Flocking

Used to build: Path following


Revision 4 · 2 sources · Something wrong? Tell us.