How understand make signal?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By abbos

Hi, I know how to make a simple signal, but in practice I get lost. Can anyone help me understand how to make a signal?

:bust_in_silhouette: Reply From: putskan

If you’re talking about a custom signal, those are the general steps:

Creating & emitting the signal:

  1. Create the signal in the relevant script/node, using - signal signal_name(var1, var2, …)
  2. In the same script, when needed, trigger the signal using - emit_signal(‘signal_name’)

Catching the signal from another script:

  1. Get a handle of the previous node using - get_node(), find_node(), etc.
  2. Catch the signal from another script using - node.connect(“signal_name”, self, “function_to_call_to”)

That way, you catch the signal and run a custom function when it occurs.

Signals are pretty well documented, so I’d suggest the following resources: