2020-03-01 23:18:15 +00:00
|
|
|
extends Camera
|
|
|
|
|
2020-03-19 15:57:31 +00:00
|
|
|
const TRANSLATION_SPEED : float = 0.1
|
|
|
|
const ROTATION_SPEED : float = 0.025
|
2020-03-01 23:18:15 +00:00
|
|
|
|
2020-09-27 15:08:20 +00:00
|
|
|
var players = []
|
|
|
|
var index : int = 0
|
|
|
|
var locked : bool = false
|
|
|
|
|
|
|
|
func register_player(player):
|
|
|
|
players.append(player)
|
|
|
|
|
2020-03-01 23:18:15 +00:00
|
|
|
func _physics_process(delta : float) -> void:
|
|
|
|
if Input.is_action_pressed("camera_forward"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(0, 0, -1)); locked = false
|
2020-03-01 23:18:15 +00:00
|
|
|
if Input.is_action_pressed("camera_backward"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(0, 0, 1)); locked = false
|
2020-03-01 23:18:15 +00:00
|
|
|
if Input.is_action_pressed("camera_strafe_up"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(0, 1, 0)); locked = false
|
2020-03-01 23:18:15 +00:00
|
|
|
if Input.is_action_pressed("camera_strafe_down"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(0, -1, 0)); locked = false
|
2020-03-01 23:18:15 +00:00
|
|
|
if Input.is_action_pressed("camera_strafe_right"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(1, 0, 0)); locked = false
|
2020-03-01 23:18:15 +00:00
|
|
|
if Input.is_action_pressed("camera_strafe_left"):
|
2020-09-27 15:08:20 +00:00
|
|
|
translate(TRANSLATION_SPEED * Vector3(-1, 0, 0)); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_pitch_down"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(1,0,0), -ROTATION_SPEED); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_pitch_up"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(1,0,0), ROTATION_SPEED); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_roll_left"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(0,0,1), ROTATION_SPEED); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_roll_right"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(0,0,1), -ROTATION_SPEED); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_yaw_left"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(0,1,0), ROTATION_SPEED); locked = false
|
2020-03-19 15:57:31 +00:00
|
|
|
if Input.is_action_pressed("camera_yaw_right"):
|
2020-09-27 15:08:20 +00:00
|
|
|
rotate_object_local(Vector3(0,1,0), -ROTATION_SPEED); locked = false
|
|
|
|
if Input.is_action_just_pressed("camera_switch_player"):
|
|
|
|
move_to_player(index % len(players))
|
|
|
|
index += 1
|
|
|
|
locked = true
|
|
|
|
if locked:
|
|
|
|
move_to_player(index % len(players))
|
|
|
|
|
|
|
|
func move_to_player(index : int):
|
|
|
|
translation = players[index].translation
|
|
|
|
rotation = players[index].rotation
|
|
|
|
translate(Vector3(0, -0.8, -2))
|
|
|
|
rotate_object_local(Vector3(1,0,0), PI-0.3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|