#Working With Signals

7 messages · Page 1 of 1 (latest)

coral geode
#

i'm currently trying to become more familiar with signals and how they work.
I would like to send this signal to my player script where i can add the item data to my players variables does anyone know how i would go about connecting this signal

clear crystal
# coral geode i'm currently trying to become more familiar with signals and how they work. I w...

I'm not good with English but I try to help. The signal is like a mediating pattern.

One node can send a signal and another node can receive it and do something about it. In this way, two or more nodes can communicate without knowing each other, something that is very important in aggregation systems.

To send a signal just put

signal.emit()

another node can connect to the signal to listen to it and do something

signal.connect(do_something())

func do_something():
  .....

The trick for a signal to be heard is in the mediator. The mediator is a node that does need to know those who are going to communicate. In this way, he is in charge of making the connection.

clear crystal
# clear crystal

that is the theory part.
In Godot, the mediator always must to be a parent node, or a Autoload if the sceneTree is to complex.

MainNode
  |
  NodeA
  |
  NodeX
    |
    NodeB

MainNode must to be the meditor to connect NodeA and Node B.

coral geode
#

Thank you for the help i'm still trying to learn how to code and Im not entirely sure that im asking the right question to solve the problem ive ran into

coral geode
#

I figured it out!!

clear crystal