Do you always need to manually connect each trap when you add it to the level?

In this lesson, we had to manually connect the signals from each trap when we added them to the level even though the function names were the same. I can imagine this would be cumbersome if you had many different types of trap and many different levels. Maybe this gets covered later in the course, but is there a better way to do this? Like, programmatically connect the signal every time you instantiate a new child scene that emits a signal that has already been connected from a previous child scene?

I imagine there is a way to do this programmatically as signals do have .emit and .connect options in GDscript but its a little beyond the level of complexity in a beginner course as a first introduction.
We do touch on doing something similar in our new 3D course but it is contained to one scene, Memory is failing at the moment on how to do this accross multiple scenes but its possibly using a for loop when loading a new scene and then connecting those signals.

Iā€™d have to dig a little deeper to find out but please do let me know if you decide to look into this further :slight_smile:

1 Like

Thanks for the reply, Marc. It turned out there was a solution presented two lessons later, namely to iterate over an array of all the elements in the scene using a for loop, as you mention. :slight_smile:

nice one yea, was about to mention its covered in the arrays and then the for loop lectures.

brill that your thinking ahead for possible bottlenecks or solutions down the road.
keep it up :muscle:


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms