extends KinematicBody
-const SPEED = 20
+const SPEED_FORWARD = 2
+const SPEED_TURN = 120
+const SPEED_AIM = PI / 2
+const FRICTION = 0.95
var velocity = Vector3()
pass # Replace with function body.
func get_player_input(delta):
- var cam_vec_lateral = $Camera.transform.basis.x
- var cam_vec_vertical = $Camera.transform.basis.y
+ var vec_lateral = transform.basis.x
+ var vec_vertical = transform.basis.y
if Input.is_action_pressed("player_left"):
- velocity += SPEED * cam_vec_lateral * delta
+ velocity += SPEED_TURN * -vec_lateral * delta
elif Input.is_action_pressed("player_right"):
- velocity += SPEED * -cam_vec_lateral * delta
+ velocity += SPEED_TURN * vec_lateral * delta
if Input.is_action_pressed("player_up"):
- velocity += SPEED * cam_vec_vertical * delta
+ velocity += SPEED_TURN * vec_vertical * delta
elif Input.is_action_pressed("player_down"):
- velocity += SPEED * -cam_vec_vertical * delta
+ velocity += SPEED_TURN * -vec_vertical * delta
+
+ if Input.is_action_pressed("player_aim_up"):
+ rotate_object_local(Vector3.RIGHT, SPEED_AIM * delta)
+ elif Input.is_action_pressed("player_aim_down"):
+ rotate_object_local(Vector3.RIGHT, -SPEED_AIM * delta)
+ if Input.is_action_pressed("player_aim_left"):
+ rotate(Vector3.UP, SPEED_AIM * delta)
+ elif Input.is_action_pressed("player_aim_right"):
+ rotate(Vector3.UP, -SPEED_AIM * delta)
-func _process(delta):
- # move foward according to the camera's POV
- var cam_vec_forward = $Camera.transform.basis.z
- velocity += SPEED * -cam_vec_forward * delta
+func _process(delta):
# get velocity changes player asks for
get_player_input(delta)
+ # move foward according to the camera's POV
+ var vec_forward = transform.basis.z
+ velocity += SPEED_FORWARD * -vec_forward * delta
+
func _physics_process(_delta):
velocity = move_and_slide(velocity, Vector3.UP)