Godot - Trigger when player passes through an area

3.5k Views Asked by At

I'm trying to have a finished start of the game, where when the player passes through the finish line (an area node) it will just print finished.

I set up my area with a collision shape, then connected it to my world spatial.

Then put a group on the area so when entered and is in the group it would print. But nothing happens.

 func _on_Area_body_entered(body):
    if body.is_in_group("Player"):
        print('finished')

If I do the same code without the if body.is_in_group then it does print, but it also triggers on game first load.

1

There are 1 best solutions below

1
On BEST ANSWER

Double check that your player is in the "Player" group.

Select your player in the Scene and then go to:

Add your player to the "Player" group

Or in your Player script:

func _ready():
    add_to_group("Player")