#connecting signal when loading scene

8 messages · Page 1 of 1 (latest)

oak path
#

I mean, is a SignalManager Autoload what you want where you are able to emit a signal from any scene, or are you more trying to get data to persist from scene to scene?

rocky saddle
#

I have characters with area 2ds in each scene that detect if a player can interact with them, currently for testing purposes I just direct connected the signal from the npc to the player, now moving forward trying to load the characters from outside the scene into it disconnects the signal. would a signal manager be best for this kind of thing as i've never really messed with autoloads before

oak path
#

That's a big run-on sentence with inconsistent punctuation and capitalization. Being more consistentent with that will make it easier for people to give you help.

What you're describing is 'hard coupling', or 'coupling to concretions'. Which is to say that those specific references between the two things mean that they can't exist without each other. While that can be fine for a prototype, you're discovering why decoupling is a valuable idea.

Without more details it's difficult to say exactly what you need, but I think this video on signals might be useful

https://youtu.be/bkmXd1hHPVw

#

Now for autoloads and why they're useful, look at the root node of your level. Well, that's not the ROOT root of the project, that's the root of your level. So it looks like

  • Root
  • Level
#

But an Autoload is ALWAYS loaded at the start, making it a sibling of the Level

  • Root
  • Level
  • SignalManager

This means that even if you change your level to a new level, the SignalManager is still there, and is always accessible.

#

Also, you can make SCRIPTS or SCENES autoloads. Which means that data that you always want to be accessible (like background music or sound effects) can live in a scene that's always available.

#

A signal manager is very useful, but you want to use it for things that have a many-to-one relationship. So a good candidate for a signal manager would be something like background music where MANY scenes might need to access ONE background audio. Or sound effects tied to MANY buttons that play ONE sound effect.

Figuring out best use cases for a manger takes some practice, but it's an easy way to give you the option to trigger something from any scene.

rocky saddle
#

Alright, I think I understand now. Thank you!