How to connect a signal to an instanced scene

There’s nothing really wrong with your code :slight_smile: This code doesn’t allow match I’d say as it uses objects, though it could perhaps be solved by having const for the preloads, but it’s not really an issue, so no worries, people can be nitpicky or opinionated on how code shouldl be written, but if it works for you it works for you, and I don’t find this code particularly hard to read

1 Like

Thank you, Thousands :sob: :sparkling_heart: You’re so kind!
I’m an artist, so let me know if you’d like me to sketch something for you as a thank you gift.

As for the code, I don’t know what it means that it doesn’t allow to match and I didn’t know constants can be used on preloads, so that’s good to know.
Also I don’t mind changing my code. I was actually planning to make it more efficient, if I could.
The guy above just pissed me off a lil, since he came here to complain rather than to contribute to solving the main issue and he seemed like he didn’t even knew what he was talking about. Even I know that “elif” and “else” aren’t taken into consideration if “if” equals “true”.

1 Like

I can try out some ideas for the code if you like, and thank you so much for the offer! I will consider, it means a lot!

1 Like

Oh, if that wouldn’t be a problem for you, I’d appreciate that :sparkling_heart:
Though, I really want to learn the rules, so if you know a good youtube guide that’d be great too!

1 Like

Fair enough, my original response wasnt even serious, it wasn’t meant to upset.

Just passing on some friendly advice thats all .

Ok so I found a funny thing:

for enemy in enemy_group:
		if enemy == wooddog_PLOAD:
			var wooddog_ins = wooddog_PLOAD.instantiate()
			if pos1_taken == false:
				wooddog_ins.global_position = pos1.global_position
				pos1_taken = true
			elif pos2_taken == false:
				wooddog_ins.global_position = pos2.global_position
				pos2_taken = true
			elif pos3_taken == false:
				wooddog_ins.global_position = pos3.global_position
				pos3_taken = true
			else:
				wooddog_ins.global_position = pos4.global_position
				pos4_taken = true
			add_child(wooddog_ins)
			get_parent().mouse_entered.connect(wooddog_ins._on_mouse_entered)
			get_parent().mouse_exited.connect(wooddog_ins._on_mouse_exited)

connecting the signal from the root node of the battle scene doesn’t work if the signal is already connected to the node the signal came from (it also tells me that it can not be connected for this very reason)
So in the line responsible for connection, instead of using “wooddog_ins”, I used “get_parent()” and it kinda worked (not really)
I opened the scene and three doggos spawned and I noticed that the targets started appearing and disappearing, all at the same time. Then I realised that they were doing that whenever my mouse cursor kept entering and exiting the game window/scene window.
I need to figure out how to do that with each dog’s area2D and without affecting all of the dogs.

1 Like