SpaceClient/Scripts/Camera.gd

31 lines
1.3 KiB
GDScript

extends Camera
const TRANSLATION_SPEED : float = 0.1
const ROTATION_SPEED : float = 0.025
func _physics_process(delta : float) -> void:
if Input.is_action_pressed("camera_forward"):
translate(TRANSLATION_SPEED * Vector3(0, 0, -1))
if Input.is_action_pressed("camera_backward"):
translate(TRANSLATION_SPEED * Vector3(0, 0, 1))
if Input.is_action_pressed("camera_strafe_up"):
translate(TRANSLATION_SPEED * Vector3(0, 1, 0))
if Input.is_action_pressed("camera_strafe_down"):
translate(TRANSLATION_SPEED * Vector3(0, -1, 0))
if Input.is_action_pressed("camera_strafe_right"):
translate(TRANSLATION_SPEED * Vector3(1, 0, 0))
if Input.is_action_pressed("camera_strafe_left"):
translate(TRANSLATION_SPEED * Vector3(-1, 0, 0))
if Input.is_action_pressed("camera_pitch_down"):
rotate_object_local(Vector3(1,0,0), -ROTATION_SPEED)
if Input.is_action_pressed("camera_pitch_up"):
rotate_object_local(Vector3(1,0,0), ROTATION_SPEED)
if Input.is_action_pressed("camera_roll_left"):
rotate_object_local(Vector3(0,0,1), ROTATION_SPEED)
if Input.is_action_pressed("camera_roll_right"):
rotate_object_local(Vector3(0,0,1), -ROTATION_SPEED)
if Input.is_action_pressed("camera_yaw_left"):
rotate_object_local(Vector3(0,1,0), ROTATION_SPEED)
if Input.is_action_pressed("camera_yaw_right"):
rotate_object_local(Vector3(0,1,0), -ROTATION_SPEED)