Saving dynamically created signal connections with PackedScene

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

I’m trying to create a level-builder for my game.

One of the obvious features is an enemy spawn point. However, spawns can be triggered by several different things - instantly, on a timer, when a player enters an Area2D, etc.

So the level-builder needs to be able to dynamically create the signal connection between the spawn point and whatever triggers it. However, these connections don’t seem to be saved to the scene when saved (whereas the Godot editor-set connection for the player spawn does).

Is there anything I can do about this? From what I can find in the documentation, it seems to assume if you’re making a connection dynamically then you know how to make the connection and wouldn’t need to save it, which I can understand, but isn’t always true.

And yes, I can get round this by saving the connection details in exported variables myself and using those to recreate the connection on level load, but that just seems a pain when there already is the facility to save and load signal connections.


:bust_in_silhouette: Reply From: JestersGhost

…and I find the answer again just after I ask :confused: Sorry!

So again, for future reference:

CONNECT_PERSIST is the flag you need.

1 Like