3 const SPEED_FORWARD = 2
5 const SPEED_AIM = PI / 2
8 var velocity = Vector3()
10 # Called when the node enters the scene tree for the first time.
12 pass # Replace with function body.
14 func get_player_input(delta):
15 var vec_lateral = transform.basis.x
16 var vec_vertical = transform.basis.y
19 if Input.is_action_pressed("player_left"):
20 velocity += SPEED_TURN * -vec_lateral * delta
21 elif Input.is_action_pressed("player_right"):
22 velocity += SPEED_TURN * vec_lateral * delta
24 if Input.is_action_pressed("player_up"):
25 velocity += SPEED_TURN * vec_vertical * delta
26 elif Input.is_action_pressed("player_down"):
27 velocity += SPEED_TURN * -vec_vertical * delta
29 if Input.is_action_pressed("player_aim_up"):
30 rotate_object_local(Vector3.RIGHT, SPEED_AIM * delta)
31 elif Input.is_action_pressed("player_aim_down"):
32 rotate_object_local(Vector3.RIGHT, -SPEED_AIM * delta)
34 if Input.is_action_pressed("player_aim_left"):
35 rotate(Vector3.UP, SPEED_AIM * delta)
36 elif Input.is_action_pressed("player_aim_right"):
37 rotate(Vector3.UP, -SPEED_AIM * delta)
41 # get velocity changes player asks for
42 get_player_input(delta)
44 # move foward according to the camera's POV
45 var vec_forward = transform.basis.z
46 velocity += SPEED_FORWARD * -vec_forward * delta
48 func _physics_process(_delta):
49 velocity = move_and_slide(velocity, Vector3.UP)