godot_recipes icon indicating copy to clipboard operation
godot_recipes copied to clipboard

[Discussion] Basics: Node Communication (the right way)

Open cbscribe opened this issue 5 years ago • 7 comments

Comments for http://godotrecipes.com/basics/node_communication/

cbscribe avatar Feb 03 '21 01:02 cbscribe

So if I only want 1 enemy to die with the Galaga example, and they are part of a group just because, how do I handle that? At the moment I have a project where my enemy units (KB2D) are in the group. Once an enemy is killed then all are killed because I'm calling the group from the player node so that the player can find it.

brobruno51 avatar May 31 '21 14:05 brobruno51

@brobruno51 it depends, what exactly are you wanting to do? Is it that all enemies except that 1 should be immune to the attack? Or the attack is targeting the 1 specific enemy? Or what?

TheRektafire avatar Jun 03 '21 05:06 TheRektafire

Hi. Yes the attack is just targeting 1 specific enemy. I did figure it out in the end. I was calling all enemies in a group. I can't remember what I did to fix it, but basically I managed to isolate it. Thanks for the reply.

brobruno51 avatar Jun 03 '21 07:06 brobruno51

Hi! I've been having a similar problem to @brobruno51 , where there is a drag-and-drop item instanced in code. It has a signal so that when a body enters it, it prints a message to the console, but it doesn't fire when it is entered by a StaticBody2D. I didn't know if this was a communication problem or something else, but with the amount of code-checking I've done, I've wondered if it was a communication problem, or a problem with it being an instanced scene. Just thought I'd ask. Thanks in advance!

StevenStevenStevenS avatar Jun 05 '21 20:06 StevenStevenStevenS

When you say "entered by a StaticBody2D", are you moving the static body?

cbscribe avatar Jun 06 '21 00:06 cbscribe

No, I was moving an Area2D into a StaticBody2D. Somehow, restarting the project (remaking all the nodes in new scenes in a different Godot project seemed to do the trick. They're not all the same as they were in the first project, so I'm not sure if it was a glitch, or I did something and didn't realize I was messing everything up. Thanks for replying!

StevenStevenStevenS avatar Jun 06 '21 21:06 StevenStevenStevenS

(note I'm new to Godot/GDscript). I was trying the "Signal example" in a dummy project and found that it wasn't working. In Object of type 'Node': Attempt to connect nonexistent signal I found out by doing another tutorial that I had to define signal in the Node where I'm emitting my signal from. Perhaps it could help others to include that information in the document?

PieterIng avatar Jul 14 '21 07:07 PieterIng