30 lines
900 B
Plaintext
30 lines
900 B
Plaintext
|
|
extends Node3D
|
||
|
|
|
||
|
|
var followTarget: Node3D
|
||
|
|
var followedPlayerIndex: int = 0
|
||
|
|
var mouseSensetivity: float = 0.1
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
activateCamera()
|
||
|
|
|
||
|
|
func _process(_delta: float) -> void:
|
||
|
|
updateFollowTarget()
|
||
|
|
if followTarget:
|
||
|
|
global_position = followTarget.global_position
|
||
|
|
|
||
|
|
func _input(event: InputEvent) -> void: #Camera movement with mouse
|
||
|
|
if event is InputEventMouseMotion && Input.mouse_mode == 2:
|
||
|
|
rotation.x = clampf(rotation.x - deg_to_rad(event.relative.y * mouseSensetivity),-PI/8,PI/4)
|
||
|
|
rotation.y -= deg_to_rad(event.relative.x * mouseSensetivity)
|
||
|
|
|
||
|
|
func updateFollowTarget() -> void:
|
||
|
|
if Input.is_action_just_pressed("throw"):
|
||
|
|
followedPlayerIndex += 1
|
||
|
|
if followedPlayerIndex >= Multiplayer.playerDict.size():
|
||
|
|
followedPlayerIndex = 0
|
||
|
|
|
||
|
|
followTarget = Multiplayer.playerDict.values()[followedPlayerIndex]
|
||
|
|
|
||
|
|
func activateCamera() -> void:
|
||
|
|
$SpringArm3D/Camera3D.current = true
|