HeyImArt
HeyImArt

Reputation: 538

Godot - Trigger when player passes through an area

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.

Upvotes: 0

Views: 5126

Answers (1)

mikatuo
mikatuo

Reputation: 800

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")

Upvotes: 1

Related Questions