โ† All examples

godot components

Top-down eight-way movement with acceleration and friction

Move a CharacterBody2D in eight directions with acceleration, friction, a reversal boost, optional d-pad snapping and a facing sector index for animation.

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • baltor_test.gd
  • component.json
  • example.tscn
  • inspect_gdscript.py
  • run_tests.gd
  • test_package.py
  • tests/test_top_down_movement_2d.gd
  • top_down_movement_2d.gd
  • verification/native.json

How it works

Class
BaltorTopDownMover2D, extends CharacterBody2D
Methods
set_input(direction: Vector2) -> void; get_input() -> Vector2; get_facing() -> Vector2; get_facing_index(sectors: int = 8) -> int; step(delta: float) -> Vector2
Signals
facing_changed
Exports
max_speed, acceleration, friction, turn_boost, snap_eight_directions, use_input_actions, action_left, action_right and 2 more
Placement
res://baltor/godot_components/top_down_movement_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_example_scene
  • godot_readme_usage_compiles

Limits to consider

Set the body's motion_mode to Floating for top-down games (the example scene does). No dodge, knockback or terrain speed modifiers; combine with the dash and knockback components. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.