From 8c227de86844556d5148f4142fc3a3010018d6e3 Mon Sep 17 00:00:00 2001 From: okpom <97510169+okpom@users.noreply.github.com> Date: Thu, 23 Oct 2025 01:28:08 -0700 Subject: [PATCH] Fix camera selector startup bug There seems to be some sort of race condition or something of that sort that causes the camera at the top of the scene tree to be made the current camera due to the code in the `_ready()` function in `camera_selector.gd` not executing in time. Achieves seemingly the same result as https://github.com/dr-jam/CameraControlExercise/pull/1. --- Obscura/scripts/camera_selector.gd | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Obscura/scripts/camera_selector.gd b/Obscura/scripts/camera_selector.gd index 6cf2f16..c571d55 100644 --- a/Obscura/scripts/camera_selector.gd +++ b/Obscura/scripts/camera_selector.gd @@ -8,7 +8,7 @@ var current_controller:int = 0 func _ready(): for camera in cameras: if null != camera: - camera.current = false + (func (): camera.current = false).call_deferred() if(len(cameras) > current_controller+1): cameras[current_controller].make_current() @@ -18,7 +18,7 @@ func _process(_delta): current_controller += 1 if len(cameras) < current_controller+1: current_controller = 0 - + for index in len(cameras): if null != cameras[index]: if index == current_controller: @@ -32,7 +32,3 @@ func _process(_delta): if null != cameras[index]: current_controller = index cameras[current_controller].make_current() - - - -