The_Dark_Side_of_Earth/utils/earth_aligner.gd

19 lines
444 B
GDScript3
Raw Normal View History

extends Node2D
var parent : Node2D
@export var center = Vector2.ZERO
var angle = 0
func _ready() -> void:
parent = get_parent()
2025-09-16 14:59:40 +02:00
func _physics_process(_delta: float) -> void:
angle = -(parent.position - center).angle_to(Vector2.UP)
parent.rotation = angle;
2025-09-16 14:59:40 +02:00
func global_from_local (_velocity: Vector2) -> Vector2:
return _velocity.rotated(angle)
func local_from_global (_velocity: Vector2) -> Vector2:
return _velocity.rotated(-angle)