Planet-Miner/godot/Camera3D.gd

20 lines
510 B
GDScript

extends Camera3D
var velocity: Vector3
var acceleration: Vector3
var g : float = 0.1
# Called when the node enters the scene tree for the first time.
func _ready():
acceleration = -global_position.normalized()
velocity = Vector3(0.05, 0, 0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
acceleration = -global_position.normalized() * g / global_position.length_squared()
velocity += acceleration
global_translate(velocity)
look_at(Vector3(0,0,0))