19 lines
632 B
GDScript
19 lines
632 B
GDScript
extends KinematicBody
|
|
|
|
const MAX_ANGULAR_VELOCITY = deg2rad(135.0) # rad/s
|
|
const MAX_VELOCITY = 600.0 # m/s
|
|
|
|
func _physics_process(delta):
|
|
rotate_y(Input.get_axis("right", "left") * MAX_ANGULAR_VELOCITY * delta)
|
|
var movement_input = Vector3(0.0, 0.0, Input.get_axis("down", "up"))
|
|
move_and_slide(transform.basis.xform(movement_input) * MAX_VELOCITY * delta)
|
|
update_audio(movement_input.length_squared() > 0.1)
|
|
|
|
func update_audio(is_moving: bool):
|
|
if is_moving != $AudioStreamPlayer.playing:
|
|
$AudioStreamPlayer.playing = is_moving
|
|
|
|
func _on_HitBox_area_entered(area: Area):
|
|
if area.is_in_group("pickup"):
|
|
area.queue_free()
|