0 votes

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

Godot version 3.5
in Engine by (18 points)

1 Answer

0 votes

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

by (517 points)

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.