โ† All examples

godot components

Group camera that zooms to fit several targets

Center a Camera2D on several targets and zoom so all of them fit with a margin, within zoom limits and with smoothing, for local multiplayer and boss fights.

What this component contains

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

How it works

Class
BaltorGroupCamera2D, extends Camera2D
Methods
fit(points: PackedVector2Array, view_size: Vector2, border: float, smallest: float, largest: float) -> Dictionary; update_camera(points: PackedVector2Array, view_size: Vector2, delta: float) -> void
Exports
targets, margin, min_zoom, max_zoom, follow_speed
Placement
res://baltor/godot_components/zoom_to_fit_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

Fits the axis-aligned bounds of target positions, not their sprites; raise the margin for large characters. Uses the viewport size, so stretch settings change the result. Verified with Godot 4.7.2 headless; written against the Godot 4.3 API.