Godot version
4.3 stable
Question
`Hello everyone,
I’m currently working on a project in Godot where I need to switch between multiple cameras based on signals received from a dialogue system (using Dialogic). However, I’m facing an issue where the camera does not switch as expected, and I could really use some help.
Here’s a brief overview of my setup:
I have five Camera3D nodes in my scene: Camera1, Camera2, Camera3, Camera4, and Camera5.
I am using a script attached to a Node3D that manages the camera switching.
I am receiving signals correctly from Dialogic, as confirmed by debug prints in the console.
extends Node3D
@export var timeline_path: String = "res://dialogue/Abelscene1.dtl"
@onready var camera1 = $Camera1 as Camera3D
@onready var camera2 = $Camera2 as Camera3D
@onready var camera3 = $Camera3 as Camera3D
@onready var camera4 = $Camera4 as Camera3D
@onready var camera5 = $Camera5 as Camera3D
var current_camera: Camera3D
func _ready():
Dialogic.signal_event.connect(_on_dialogic_signal)
Dialogic.start_timeline(timeline_path)
set_current_camera(camera1)
func set_current_camera(camera: Camera3D):
camera1.current = false
camera2.current = false
camera3.current = false
camera4.current = false
camera5.current = false
camera.current = true
current_camera = camera
func _on_dialogic_signal(argument: String):
if argument == "billalcamera":
set_current_camera(camera2)
elif argument == "abelcamera":
set_current_camera(camera3)
elif argument == "billalcamera1":
set_current_camera(camera1)
func _input(event):
if event.is_action_pressed("ui_accept"):
switch_camera()
func switch_camera():
if current_camera == camera1:
set_current_camera(camera2)
elif current_camera == camera2:
set_current_camera(camera3)
elif current_camera == camera3:
set_current_camera(camera1)
The Problem:
Despite receiving the signals correctly (as confirmed by debug prints), the camera does not switch from Camera1 to Camera2 or Camera3.
I have verified that the cameras are positioned correctly in the scene and that their current property is being set to true for the active camera.
I have also tried using set_process(false) and set_process(true) to manage camera processing, but that did not resolve the issue.
What I’ve Tried:
Ensured that all camera nodes are direct children of the node that the script is attached to.
Added debug prints to confirm which camera is currently active.
Created a simple test scene with just two cameras to isolate the problem.
I would greatly appreciate any insights or suggestions on what might be going wrong. Thank you in advance for your help!