#How do multiple instances work with signals

10 messages · Page 1 of 1 (latest)

old notch
#

I have a snowball scene that the player instantiates and throws . In that snowball instance the script connects a signal to the level manager. Does each snowball instance re-connect every time it's created? Does the signal connect to that specific instance or the snowball scene.

I'm trying to avoid having every instance have to individually connect signals. Also to clarify some more I have a signal in the snowball script and I connect that to the level manager in that same snowball script.

I'm trying to figure out the best way for a short lived instance to convey information to the level manager when a particular event happens.

Thank you for your time. Any help is appreciated, I have looked at the signal documentation but I couldn't find anything that clarified how this works.

bright geyser
#

It depends on the number of snow balls you expect. If it's not a lot, you can connect the signal in the _ready method, so each instance will have its own connection to the signal yes, and it should not be a problem.

If you have a lot of snow balls and they must all react the same way, you can connect the signal on their parent, that will loop over all the snow ball instances and do the required action when it receives the signal.

Both approaches are valid IMHO

old notch
#

Thanks for the info btw.

stiff vine
#

Each instance has its own signal connection, and that should be just fine. That's what you want, since you want each instance to be able to operate independently

bright geyser
#

and it initializes all its properties

old notch
#

Well this basically answers my questions so thanks to both of you