Changing camera.current whilst game is running doesn't do anything

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LeipeMeuteLeider

I’m currently trying to make a little notes system that I can link to each node to keep notes on everything organized and with relevant references to the nodes themselves. Trying to get started on that, I came across a problem: no matter what I try, I don’t seem to be able to change the camera from the one that is following the player to the one moving around my notes. I’m even printing the camera.current variable before and after to check that it goes from false to true, and it does, but no change in camera. It works just fine if I do the exact same thing(setting current to true) in the editor but in code, no cigar. What could I be doing wrong here?

extends Node
onready var notes_cam = get_node("NoteSystem/Viewport/Camera2D")
onready var player_cam = get_node("Game/PlayerCharacter/PlayerCamera")

func _input(event):
if event is InputEventKey:
	if event.is_action_pressed("notes"):
		print(notes_cam.current)
		player_cam.current = false
		notes_cam.current = true
		print(notes_cam.current)

Output:
False
True

:bust_in_silhouette: Reply From: SteveSmith

As per https://forum.godotengine.org/50561/how-to-switch-between-cameras-with-set_current , you always need one current camera. Try setting notes_cam to be current first.

I have tried this before, and unfortunately it didn’t work(checked again just now, still no cigar)

LeipeMeuteLeider | 2022-09-29 14:52

Have you checked the camera positions, i.e. it’s not something daft like both your cameras are in the same place?

SteveSmith | 2022-09-29 15:14