โ† All examples

godot components

Artificial potential field navigation

Navigate in 2D with an artificial potential field: goals attract with constant force, obstacles repel inside an influence radius, forces are analytic gradients, and a walker reports whether it reached the goal or stalled in a local minimum.

What this component contains

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

How it works

Class
BaltorPotentialField, extends RefCounted
Methods
add_attractor(point: Vector2, strength: float = 1.0) -> void; add_repulsor(point: Vector2, strength: float, influence_radius: float) -> void; clear() -> void; potential_at(point: Vector2) -> float; force_at(point: Vector2) -> Vector2; follow(start: Vector2, step_length: float, max_steps: int = 500, goal_radius: float = 1.0, min_force: float = 0.001) -> Dictionary
Placement
res://baltor/godot_components/potential_field/

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

Local method: it can stall in local minima, for example when an obstacle sits exactly between agent and goal; follow() reports that instead of hiding it. Point obstacles with a radius only. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.