28 lines
840 B
GDScript
28 lines
840 B
GDScript
extends CharacterBody3D
|
|
|
|
@export var acceleration: Vector3
|
|
@export var mouse_sensitivity : float = 0.01
|
|
var g : float = 0.006
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
global_position = Vector3(0,0,-4000)
|
|
acceleration = -global_position.normalized()
|
|
velocity = Vector3(1.3, 1.8, 0)
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
acceleration = -global_position.normalized() * g
|
|
velocity += acceleration
|
|
global_translate(velocity)
|
|
Global.camera_position = global_position
|
|
print(get_slide_collision_count())
|
|
|
|
|
|
func _unhandled_input(event):
|
|
if event is InputEventMouseMotion:
|
|
rotate_y(-event.relative.x * mouse_sensitivity)
|
|
$Pivot.rotate_x(-event.relative.y * mouse_sensitivity)
|
|
$Pivot.rotation.x = clamp($Pivot.rotation.x, -1.2, 1.2)
|