2 extends CharacterBody3D
10 @onready var _skin = $skin
13 @export_category("Movement")
14 @export var speed = 5.0
16 @export_category("Camera")
17 @export var distance = 3.0
20 @onready var _springArm = $SpringArm3D
22 enum state {ALIVE, DEAD}
23 var _state = state.ALIVE
25 func _ready() -> void:
26 _springArm.spring_length = distance
29 func _input(event: InputEvent) -> void:
30 if _state == state.ALIVE:
31 if event.is_action_pressed("player_left"):
32 global_rotate(Vector3.UP, PI/2)
34 elif event.is_action_pressed("player_right"):
35 global_rotate(Vector3.UP, -PI/2)
38 if event.is_action_pressed("player_restart"):
39 playerRestart.emit(self)
42 func _physics_process(_delta: float) -> void:
43 if _state == state.ALIVE:
44 velocity = global_transform.basis.z * speed
46 if velocity.length() == 0:
50 func _explode() -> void:
53 playerDestroyed.emit(self)