Files
SpaceBots/.svn/pristine/6b/6bd5d294f5fd4c0dc16dd774735be4709bc6ae9f.svn-base

31 lines
950 B
Plaintext
Raw Normal View History

2026-01-21 23:51:53 +01:00
extends Node3D
@export var followTarget: Node3D
var followedPlayerIndex: int = 0
var mouseSensetivity: float = 0.1
func _ready() -> void:
activateCamera()
func _process(delta: float) -> void:
if not is_multiplayer_authority(): return
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