Skip to content

Steering Behaviors Explained: Seek, Arrive, Wander and Flocking for Browser Games

abe ·

Why do fish, birds and enemies in good browser games move so naturally? Meet steering behaviors — Craig Reynolds' classic idea — and Steerkit, a tiny free library that brings them to JavaScript.

VENO cover: Steerkit demo screens with the title Steering behaviors, smooth moves

Steering behaviors are small rules that turn a goal (“go there”, “run away”, “stay with the group”) into smooth, believable movement. Instead of snapping a character straight to a target, each rule pushes it a little every frame, so it curves, slows down, dodges and swarms like something alive. The idea comes from Craig Reynolds, and a new open-source library called Steerkit packs it into a few kilobytes of JavaScript for browser games.

If you play casual games, you have seen steering everywhere: a school of fish that splits around a shark, a pet that trots after you and stops at your feet, zombies that crowd a door without stacking on one pixel. If you make web games, this guide shows how those moves are built and how to try them in an afternoon.

Quick facts

What Steering behaviors: rules that move “autonomous characters” naturally
Origin Craig Reynolds — Flocks, Herds, and Schools (SIGGRAPH 1987) and Steering Behaviors For Autonomous Characters (GDC 1999)
Library in the news Steerkit, by Thibaut Lefrançois
Version 0.4.0 on npm (October 2026)
Size About 4.1 kB for everything (minified + brotli); seek alone is 170 B
Works with Plain JavaScript/TypeScript objects, Three.js, or your own engine’s vectors
Price / licence Free, MIT licence
Try it Interactive demos for every behavior

Steerkit project artwork showing seek, arrive and wander arrows on a dark background, image: Thibaut Lefrançois / Steerkit

What are steering behaviors?

Reynolds splits a moving character into three layers:

  1. Action selection — where to go. This is your game logic: “chase the player”, “return to the nest”.
  2. Steering — how to get there: speed up, turn, brake, avoid that rock.
  3. Locomotion — how it looks: the walk cycle, the flapping wings, the wobble of a slime.

Steering behaviors live in the middle layer. The character is treated as a simple point with a position, a velocity, a top speed (maxSpeed) and a limit on how hard it can turn or accelerate (maxForce). A low maxForce turns like a ship; a high one turns like a fly.

The core trick fits in one sentence: the steering force is the velocity the character wants, minus the velocity it already has. Every frame you compute that difference, cap it, and add it to the velocity. Because the change is gradual, the path curves instead of jumping.

The basic behaviors, one by one

Seek and flee

Seek points the “wanted velocity” straight at a target at full speed. Flee points it the other way. Seek alone has a famous flaw: the character overshoots the target and circles back, because nothing tells it to slow down.

Arrive

Arrive fixes that. Inside a slowingDistance around the target, the wanted speed drops in proportion to the distance left, so the character glides to a stop exactly on the spot. It is the behavior behind a companion that stops beside you instead of orbiting you.

Arrive demo: an agent curves toward a target and slows down inside a dashed circle, image: Thibaut Lefrançois / Steerkit

Wander

Wander is a random walk that looks natural. The character seeks a point on a circle in front of it, and that point drifts a little each frame, so the heading changes in smooth curves rather than nervous jitters. Great for idle animals, ambient fireflies or a slime patrolling a room.

Pursue and evade

Pursue seeks where a moving target will be, not where it is now — the difference between a dumb chaser and a smart one. Evade does the same in reverse.

Flocking: three rules that make a swarm

Reynolds’ 1987 “boids” model creates flocks, herds and schools from three local rules, each looking only at nearby neighbors:

  1. Separation — don’t crowd your neighbors.
  2. Alignment — head the same way as your neighbors.
  3. Cohesion — move toward the middle of your neighbors.

Add the three forces together and a group of dots suddenly behaves like birds or fish, with no leader and no script.

Flocking demo: groups of small arrows form loose flocks while an orange circle scares them away, image: Thibaut Lefrançois / Steerkit

The hard part is speed: if every boid checks every other boid, the work grows with the square of the crowd. Steerkit’s documentation reports that for 1,000 boids (Node 26 on an M1 Pro) a frame took about 12 ms when each one scanned the whole crowd, but about 0.7 ms with its built-in spatial grid, which only looks at nearby cells.

Moving through a world

Real levels have walls, rocks and roads. Steering has answers for those too:

Behavior What it does Typical game use
Obstacle avoidance Looks ahead in a corridor and turns to clear the nearest obstacle Enemies weaving through pillars
Collision avoidance Predicts when two movers would meet and steps aside Crowds of shoppers, traffic
Containment (stayWithin) Turns back before hitting the walls of a box Fish in a tank, units in an arena
Path following Stays within a band around a route Racing AI, tower-defense creeps
Flow field Goes the way a grid of directions points Wind, river currents, huge crowds
Leader following / offset pursuit Keeps a spot behind or beside a leader Squads, V-formations, pets

Obstacle avoidance demo: agents steer around round rocks toward a pointer, image: Thibaut Lefrançois / Steerkit

Path following demo: agents travel around a looping road band, image: Thibaut Lefrançois / Steerkit

One reminder from the library’s own notes: avoidance is a short-range reflex, not a full pathfinding system. For mazes and long routes you still need something like A* to choose waypoints, then steering to move between them smoothly.

Steerkit: steering behaviors in 4 kB of JavaScript

Steerkit is a new open-source library by developer Thibaut Lefrançois that implements Reynolds’ model as small, typed functions. What makes it friendly for web games:

  • Engine-agnostic. Any object with x, y, z counts as a vector — plain objects, THREE.Vector3, or your engine’s own type. For 2D canvas games you keep z at 0 and pass plane: "xy".
  • No garbage per frame. Every behavior writes into a vector you pass in, so hundreds of agents don’t feed the garbage collector.
  • Tiny and tree-shakable. About 4.1 kB for everything; import only seek and it is 170 bytes.
  • Optional Three.js adapter (steerkit/three, about 2.6 kB extra, Three.js 0.152 or later) that turns models to face their direction, draws a whole crowd in one instanced draw call and shows the forces as debug arrows.
  • Interactive demos for every behavior, with the forces drawn and sliders for each parameter — plus a “Copy prompt” button and an llms.txt file for people who code with an AI assistant.

Getting started takes one command, npm install steerkit (it ships as an ES module with TypeScript types). Each frame you compute a few behaviors for an agent, combine them and call step(agent, force, dt) once.

Combining forces: blend or prioritize

Real characters want several things at once. Steerkit offers two ways to mix them:

  • blend adds forces by weight. Simple, but two opposite forces can cancel out, leaving a character stuck between its target and a threat.
  • prioritize spends a force budget in order: the most urgent behavior (say, avoiding a wall) takes what it needs first, and the rest share what is left.

For big crowds the README recommends the allocation-free zero and add forms: it measured blend leaving about 190 KiB of garbage per frame with 1,000 agents, versus about 1 KiB with zero/add.

Flow field demo: a grid of arrows bends into a vortex and agents follow the current, image: Thibaut Lefrançois / Steerkit

How it compares

The README itself points to Yuka, a complete game-AI framework with state machines, navigation, perception and 14 steering behaviors. If you want that whole toolbox, Yuka is the bigger option; Steerkit does only steering, on the objects you already have.

Tips before you add steering to your game

  1. Start with one agent and one behavior. Make it overshoot, then make it too slow — the extremes teach you what each number does.
  2. Draw the forces. Debug arrows for velocity, wanted velocity and steering force reveal most “why did it turn there?” bugs.
  3. Clamp the frame time. After a player switches tabs, one frame can last seconds; Steerkit suggests Math.min(dt, 1 / 20) so characters don’t teleport.
  4. Put avoidance first. Give walls and obstacles priority or weight, or a target behind a rock will cancel the dodge.
  5. Use a spatial grid past a few dozen agents for flocking and crowd avoidance.
  6. Smooth speed changes. When a speed boost ends, Steerkit’s overspeedDamping lets the extra speed fade over time instead of stopping dead in one frame.
  7. Keep decisions outside steering. Choosing which door the guard runs to is game logic; steering only makes the run look good.

Aquarium demo: a Three.js tank where a school of fish swirls around rocks and a red shark, image: Thibaut Lefrançois / Steerkit

The Aquarium demo shows everything working together: a school of fish flocking on a spatial grid, avoiding rocks, staying inside the glass, and scattering when the shark hunts — then regrouping.

Further reading

FAQ

What are steering behaviors in games?

They are simple movement rules — seek, flee, arrive, wander, flocking and more — that turn a goal into a small force each frame, so characters move smoothly and look alive instead of snapping between points.

Who invented steering behaviors?

Craig Reynolds. He described flocking “boids” at SIGGRAPH 1987 and the wider set of steering behaviors in his GDC 1999 paper Steering Behaviors For Autonomous Characters.

What is the difference between seek and arrive?

Seek always heads for the target at full speed, so it overshoots and circles. Arrive slows down within a set distance and stops right on the target.

Is Steerkit free, and does it need Three.js?

Yes, it is free under the MIT licence. Three.js is optional: the core works with any objects that have x, y, z, including 2D canvas games.

Are steering behaviors the same as pathfinding?

No. Pathfinding (like A*) decides the route through a level; steering decides how a character moves along it, turning, slowing and avoiding nearby obstacles. Most games use both.

Related articles

Loading game…

VENOGAME / PLAYBOOK

My arena

Saved on this device. No account needed.

Tap a heart to build your own game collection.