I'm currently trying to create a projectile that will split and go to different direction if it detects a wall in front of it.
Here's what I would like to do:
Once the player presses a button, it will signal the main scene to spawn ( using add_child(projectile) ) a projectile at the player's location.
The projectile will go forward.
if the projectile detects a wall in front of it, it will signal the main scene to create 2 new projectiles (different to current projectile) on its location, both going in a different direction.
The problem lies in 3, as I can't find a way to connect the signal of the created projectile to the main scene. I was able to manually connect the signal of the player to the main scene's script as it was already a child of the scene, but I can't connect the signal of the projectile like the player's signal as it doesn't exist in the main scene until I start the game and press the button.
Long story short, the question is:
Is there a way to connect the signal of the spawned projectile (the node) to the main scene (parent) through a script? If it's impossible / not efficient, is there another way?
Thanks, I hope I elaborated it well enough.