The Camera2D
and Camera3D
node has make_current()
which allows you to select which camera is currently active.
For your desired result, you could make a simple script that calls make_current()
for a specific camera instance. Here is an example of what I’m describing:
class_name CameraToggle
extends Button
@export var target_camera: Camera3D
func _ready():
# Connect the function below to the 'pressed'-signal
pressed.connect(on_pressed)
func on_pressed():
# Change the current active camera to 'target_camera'
target_camera.make_current()
The caveat to this simple approach is that your UI must exist in the scene(s) where the cameras exist; the scripts requires the target_camera
variable to be set inside the editor before the game is build.
If you want inspiration for a method that is less coupled, you may look at another post similar to this one.
I hope that does it. Let me know if you need help with anything else regarding this issue.