A signal is targetting multiple variables

Godot Version

v4.2.2.stable.official [15073afe3]


I have a variable called “player” which is your standard collision player variable.
I have a variable called “killbox” which goes around the border of the screen

In the player script I have:
func _on_kill_box_body_entered(body):
end = 1

when I start to add another variable called, AI it also counts as the player collision and is killing the player when it enters the killbox.

How do I make the killbox signal ONLY count for Player and not the AI

yes of course it does kill the player, because the player script is the one receiving the signal on body entered of the killbox Area2d body_entered signal. so anyone/body that enters the killbox area, the player will receive the signal and do end=1 line

So how could I signal it so when only the player enters the death box, it triggers end = 1

does the player has its own area2d?

The player does have a area2d

ok, from that player area2d, connect the body_entered signal to the player script
then in that body_entered block code, check if the body is killbox, can either be in a group of “killboxes” and check by if body.is_in_group("killboxes"): or you actually made a script for the killbox and add class_name KillBox and check it by if body is KillBox :
if it’s either of that, then end=1

I still run into the issue of the ai killing the player
Here is the code
func _on_area_2d_body_entered(body):
if body.is_in_group(“killbox”):
end = 1

Does the body in the signal get set to the target or what entered it?

you removed and disconnected this code?

the signal you connected to should only receiving signal when player area2d entered by something, the body is the something that entered to the player area2d, then we check if the body that enter the player area2d is a killbox or not, if it’s not, then nothing will happen.

No I did not. When I removed the old code I do not instantly die.
however im running into the issue of not dying when i hit it

func _on_player_Area_body_entered(body):
if body.is_in_group(“killboxes”):
end = 1

(before you ask the killbox is set to the group “killboxes”)
Do i need to import or autoload the group?

try print(body)

between here, see if the player actually can detect the body that entered

The function is not executing as it is not printing anything

may i see your player scene tree hierachy?


  • collisionshape2D
  • player_area
    • collisionpolygon2D
  • mc skin

you sure you named the killbox group killboxes?
the player area should be able to detect any body though, this just doesnt make sense, did you toggled something on layer masking for the player area2d?

Where would I find the setting for it? I’m relatively new to Godot so I do not know how to turn it on or off

it’s here down below Area2d Inspector dock:

No I have not

can you show the Area2D node signal too?

Yeah here

this one the A of Area is in capital letter