]> Untitled Git - lightcycles.git/blob - player/player.gd
1c842d4b5c14153628d0b0a39e6506a17acc55ac
[lightcycles.git] / player / player.gd
1 class_name Player
2 extends CharacterBody3D
3
4
5 signal playerReady
6 signal playerTurn
7
8
9 @export_category("Movement")
10 @export var speed = 5.0
11
12 @export_category("Camera")
13 @export var distance = 3.0
14
15 @onready var _springArm = $SpringArm3D
16
17
18 func _ready() -> void:
19         _springArm.spring_length = distance
20         playerReady.emit(self)
21
22
23 func _input(event: InputEvent) -> void:
24         if event.is_action_pressed("player_left"):
25                 playerTurn.emit(self)
26                 global_rotate(Vector3.UP, PI/2)
27         elif event.is_action_pressed("player_right"):
28                 playerTurn.emit(self)
29                 global_rotate(Vector3.UP, -PI/2)
30
31
32 func _physics_process(_delta: float) -> void:
33         velocity = global_transform.basis.z * speed
34         move_and_slide()