![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | imalexandra |
I am programmatically instantiating a scene with the player character. When this scene is instantiated I want to send a signal to the camera. The signal should set the player character to be the target of the camera.
This is the main scene structure
GameManager
Camera
SceneSwitcher
(instantiated scene will be here)
The new scene is instantiated as a child of the SceneSwitcher. This is SceneSwitcher script where I am trying to connect the signal from the instantiated scene.
func loadScene(scene):
var newScene = load(scene).instance()
add_child(newScene)
newScene.connect("focus", camera, "setCameraTarget")
The instantiated scene is emitting this signal:
signal focus(target)
func _on_Player_tree_entered():
emit_signal("focus", player)
This is the function in the camera that I want to run when the signal connects:
func setCameraTarget(object):
print("camera set on: ", object.name)
target = object
Seems like the signal never connects because I never see the print message “camera set on: player”.