The_Dark_Side_of_Earth/utils/earth_aligner.gd
2025-09-17 12:53:16 +02:00

22 lines
478 B
GDScript

extends Node2D
var parent : Node2D
@export var center = Vector2.ZERO
var angle = 0
func _ready() -> void:
parent = get_parent()
align()
func _physics_process(_delta: float) -> void:
align()
func align():
angle = -(parent.position - center).angle_to(Vector2.UP)
parent.rotation = angle;
func global_from_local (_velocity: Vector2) -> Vector2:
return _velocity.rotated(angle)
func local_from_global (_velocity: Vector2) -> Vector2:
return _velocity.rotated(-angle)