Steering behaviors

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Steering behaviors

Steering behaviors are a suite of algorithms used to make playable characters and AIs move smoothly in various ways: following a target, slowing down when arriving at a location, following a path, following each other in a queue, etc.

The most interesting aspect of these behaviors is that they mostly rely on vector arithmetic. So, they are lightweight and generally require little code complexity. They also work the same or nearly the same in 2D and 3D, making them well worth learning.

The simplest and most basic of those behaviors is the follow steering behavior.

It works like this:

  1. We pick a target position we want to reach.
  2. We calculate a desired velocity. It is the velocity we would have if moving straight in the direction of the target at the maximum allowed speed.
  3. We calculate the difference between the current and desired velocity. We call that the steering vector.
  4. We add a fraction of that difference to the current velocity.

The code looks like this:

var max_speed := 600.0
var steering_factor := 10.0

## Reference to the node to follow.
var target: Node2D = null


func _physics_process(delta: float) -> void:
    var direction := Vector2.ZERO
    if target != null:
        direction = global_position.direction_to(target.global_position)

	var desired_velocity := max_speed * direction
	var steering_vector := desired_velocity - velocity
	velocity += steering_vector * steering_factor * delta
	position += velocity * delta

You can also skip the first step and use this equation to make a playable character accelerate and decelerate smoothly. Here's an example:

var max_speed := 600.0
var steering_factor := 10.0

func _process(delta: float) -> void:
	var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")

	var desired_velocity := max_speed * direction
	var steering_vector := desired_velocity - velocity
	velocity += steering_vector * steering_factor * delta
	position += velocity * delta

This basic steering algorithm is a form of linear interpolation.

You can use steering behaviors in combination with pathfinding to make entities follow a path smoothly and avoid each other while moving along the path. This technique is often used in real-time strategy games (RTS), among other genres.

The most common steering behaviors are:

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!