โ† All examples

godot components

Obstacle avoidance steering among circle obstacles

Steer a 2D agent around circle obstacles with a detection corridor ahead of it: find the closest threat, push sideways away from it and brake, harder when closer, with a repeatable choice for dead-ahead obstacles.

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • baltor_test.gd
  • component.json
  • inspect_gdscript.py
  • obstacle_avoidance_2d.gd
  • run_tests.gd
  • test_package.py
  • tests/test_obstacle_avoidance_2d.gd
  • verification/native.json

How it works

Class
BaltorObstacleAvoidance, extends RefCounted
Methods
ray_circle(origin: Vector2, direction: Vector2, center: Vector2, radius: float) -> float; find_threat(position: Vector2, velocity: Vector2, obstacles: PackedVector3Array, agent_radius: float, look_ahead: float) -> int; avoid(position: Vector2, velocity: Vector2, obstacles: PackedVector3Array, agent_radius: float, look_ahead: float, max_force: float) -> Vector2
Placement
res://baltor/godot_components/obstacle_avoidance_2d/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • godot_parse_check_only
  • godot_gdscript_tests
  • godot_tests_reject_gutted_component
  • godot_editor_import
  • godot_contract_reflection
  • godot_readme_usage_compiles

Limits to consider

Circle obstacles only, given as Vector3(x, y, radius); walls and polygons need another method. Avoids one obstacle at a time, so dense clusters can still trap an agent. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.