From 21a24eb959bd9e60b793c84fc86d128b7f732ce3 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Sat, 3 Jul 2021 08:58:20 +0100 Subject: [PATCH] Most recently added current Camera2D takes precedence The situation when multiple current Camera2Ds were in the scene was not dealt with. This could leave several cameras with their current bool set, and each competing to update the viewport scroll, in a random / accidental fashion. This PR standardises the rule that the most recent current Camera2D added to the scene tree takes over the current status, and sets all other current cameras in the scene tree to non-current. This makes the bools correct, and also prevents the competition over viewport scroll. --- scene/2d/camera_2d.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index f070191a11f..24d191cd4a4 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -245,9 +245,13 @@ void Camera2D::_notification(int p_what) { canvas = get_canvas(); _setup_viewport(); - _update_process_mode(); - _update_scroll(); + + // if a camera enters the tree that is set to current, + // it should take over as the current camera, and mark + // all other cameras as non current + _set_current(current); + first = true; } break;