0 votes

I am making a game where there are multiple buttons on the screen. When clicked they execute a function and then send out a signal. The main code should react in the same way no matter which button is pressed. Seeing as the name of the signal is the same for all of them it would be very convenient to connect this signal in code without specifying from which node it originates. I could not find anything useful in the documentation.
Is this possible?
P.S. Sorry if this is a very basic question but I am just getting started with Godot.

Godot version 3.2.1
in Engine by (19 points)

1 Answer

0 votes

I think you should take custom signals like:

signal test

func onButton1pressed():
emit
signal("test")

func onButton2pressed():
emit
signal("test")

func onNode_test():
print("hello World")

by (254 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 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 webmaster@godotengine.org with your username.