class_name CameraGrabber extends Node3D static var _lock: NonReentrantCoroutineMutex static func _static_init() -> void: _lock = NonReentrantCoroutineMutex.new() @export var acquire_on_ready := true var acquired := false func _ready() -> void: if acquire_on_ready: acquire() func acquire() -> void: if not acquired: await _lock.acquire() var camera := FX.get_camera() as Camera3D camera.global_transform = global_transform acquired = true func _process(_delta: float) -> void: if acquired: var camera := FX.get_camera() as Camera3D camera.global_transform = global_transform func relinquish() -> void: if acquired: acquired = false _lock.relinquish() func _exit_tree() -> void: relinquish()