#How do I make my 2D door closes automatically

4 messages · Page 1 of 1 (latest)

honest gorge
#

I already set my gdscript to allow the door opens when a player goes enter to the door. I just can't figure out how to make the door automatically close after I enter it

here's my gdscript:

extends StaticBody2D


# Called when the node enters the scene tree for the first time.
func _ready():
    pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    pass


func _on_player_detector_body_entered(body):
    if body.name == "Player":
        $AnimationPlayer.play("opened")
        await $AnimationPlayer.animation_finished
        $AnimationPlayer.play("opening")
        await $AnimationPlayer.animation_finished
        $AnimationPlayer.play("closed")

bright cipher
#

you have a "player_left" method

#

"on_player_left"

#

something like that