19 lines
530 B
GDScript3
19 lines
530 B
GDScript3
|
|
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
|