The_Dark_Side_of_Earth/player.gd
2025-09-15 19:15:43 +02:00

18 lines
530 B
GDScript

extends Node2D
var body : CharacterBody2D;
var earth_center = Vector2.ZERO;
var gravity = 500;
func _ready() -> void:
body = get_parent().get_node("Player")
func _physics_process(delta: float) -> void:
var local_velocity = Vector2.ZERO
body.up_direction = (self.position - earth_center).normalized();
local_velocity += Vector2(0, gravity)
body.velocity = global_from_local(local_velocity)
print(body.velocity)
body.move_and_slide()
func global_from_local (_velocity: Vector2) -> Vector2:
return _velocity # Placeholder