Why won't my area node collide?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Genesis689

I have put an area node under my game to respawn the player if they fall of but it won’t detect the player. I have put a box collision shape for it and I have even put a method in the code. I think the code is where I am going wrong.

func on_body_entered():
    if body.is_in_group("player"):
        body.emit_signal("death")

death is the player’s death signal so the level script can reassign coordinates to the player on its death.

:bust_in_silhouette: Reply From: Gluon

Well there are a lot of possibilities here.

  1. if the players group is called “Player” with a capital p and you have written “player” in the code above then it wont see the if block code.

  2. If you have your player and other nodes on different levels then it may be that the collision node is not set up to detect any objects on the layer your player is on and thus this function is never activated

  3. you may not have actually connected the signal of body entered to the function above

  4. you may not have added a collision layer to your player.

Based on just the above it is impossible for me to say, there may even be another option but in principle at least your code above looks fine.

thanks i’ll see if any of these possibilities is the issue

Genesis689 | 2022-12-27 19:08

Oh I have just thought of something try this

func on_body_entered(body):
    if body.is_in_group("player"):
        body.emit_signal("death")

Gluon | 2022-12-27 19:14