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