I know I can get the current active camera by calling camera.get_camera()
, but I don't want to call it every frame to find possible changes. Is there any signal or notification I can use to detect camera changes?
How to detect active camera change
You can use the VisibilityNotifier, which will let you know which camera it entered on camera_entered.
https://docs.godotengine.org/en/stable/classes/class_visibilitynotifier.html
According to your answer answer, you are suggesting that I add a VisibilityNotifier to the camera, so that I can know the camera change (caused by set_current) by connecting a method to camera_entered?
No, I think that node would be on your player or something in the scene that is triggering the camera change.
Well, actually I'm coding a debugging overlay to show entity labels. As a debugging tool, this node doesn't know when a camera change may take place or when the debugging node should abandon the current camera (maybe because it has been queuefreed. My goal is to make the debugging tool as reliable and efficient as possible.
The camera_entered signal is triggered even if the new camera is not the active one, so I can't use this approach to detect active camera change.
Well what is changing the camera? Maybe put the code there.
Currently game stage change alters camera, and so is loading a game. However, our game (Thrive) is still under development, so we can't decided what may change the camera later. They are not yet coded. Because of this, other members in the team is against modifying current code to make this debugging tool functional, so as to not causing strange problems in the future.
Maybe use the camera_entered signal, but check if it's the active camera. This will be some wasted processing, but vastly better than checking every frame.