โ† All examples

godot components

Grid flow field for many units with terrain costs

Build a Dijkstra flow field from one or more goal cells over a grid with terrain costs and walls, then read a direction per cell so any number of units can share one search.

What this component contains

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

How it works

Class
BaltorFlowField, extends RefCounted
Methods
has_cell(cell: Vector2i) -> bool; set_cost(cell: Vector2i, cost: float) -> bool; get_cost(cell: Vector2i) -> float; build(goals: Array[Vector2i]) -> int; get_distance(cell: Vector2i) -> float; direction_at(cell: Vector2i) -> Vector2; sample(point: Vector2) -> Vector2; world_to_cell(point: Vector2) -> Vector2i; and 1 more
Placement
res://baltor/godot_components/flow_field_grid/

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

Grid-based with 8 neighbors and no corner cutting; directions point to the next cell center, so units should blend them for smooth motion. Rebuilding costs O(cells log cells) in GDScript. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.