The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Hi there,

I am trying to emit a signal to my Camera but it is not being received by it.


My scene looks like this in terms of hierarchy:

  • RootNode

    • CameraParentNode

      • Camera
    • NodeWithScript

Camera has a simple script attached, which has a signal and a function that is triggered when this signal is received (this is configured via Node window in editor):


extends Camera

signal rotate_camera(direction)

func onCamerarotatecamera(direction):
print("Rotating camera!")


NodeWithScripthas a script attached that emits under certain conditions:

emitsignal('rotatecamera', Vector2(-sign(direction.x), 0.0))
print("Emmited horizontal swipe")


In runtime, I see "Emmited horizontal swipe" printed but not "Rotating camera!".
What could be the reason for the emmited signal to not be received by the camera script?

Godot version 3.2.3
in Engine by (15 points)

1 Answer

0 votes

Signal should be defined in script that emit it. So your NodeWithScript script should have next lines:

signal rotate_camera(direction)
...
emit_signal('rotate_camera', Vector2(-sign(direction.x), 0.0))
print("Emmited horizontal swipe")

And node that want to receive signal should connect to it. Your Camera should have next lines:

func _ready():
    # connect node to signal
    get_node("/root/NodeWithScript").connect("rotate_camera", self, "on_Camera_rotate_camera")

func on_Camera_rotate_camera(direction):
    print("Rotating camera!")
by (1,656 points)
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.