Individual AI units navigate around obstacles to reach dynamically assigned targets.
A unit computes the shortest route around walls with a breadth-first search, then walks it — and re-plans whenever the target moves.
Defines the walkable space. Bake your level geometry into it once; every agent queries this region for valid paths around obstacles.
# Set up the navigation polygon for the level,
# then bake it (editor or NavigationServer2D at runtime).One per unit. Set target_position when an order is issued; the agent computes the path and hands you the next point to steer toward.
agent.target_position = order_pos
var next = agent.get_next_path_position()
velocity = (next - global_position).normalized() * SPEEDThe moving body. Feed the agent's suggested velocity into move_and_slide so units physically follow their computed paths and avoid each other.
func _physics_process(_d):
velocity = steer_toward(agent.get_next_path_position())
move_and_slide()In short: NavigationAgent2D per unit; target_position updated when order is issued; move_and_slide() toward next path point
18 catalogued game(s) use this mechanic, spanning 1989–1999.
▶ Explore Unit Pathfinding interactively — see every game + the Godot system