0 votes

I have a coin (Area2D) when the player entered it, it plays an animation that has a sound effect, and then queue free, and it doesn't work

func _on_Coin_body_entered(body: PhysicsBody2D) -> void:
    if body.name == "Player":
        stats.increment_coins()
        destory(true)

func play_die_anim() -> void:
     $AnimationPlayer.play("die")
     yield($AnimationPlayer, "animation_finished")

func destory(play: bool) -> void:
    if play:
        play_die_anim()
    queue_free()

Animation Player

asked Dec 11, 2019 in Projects by Andrew Maher (16 points)

1 Answer

0 votes

Instead of controlling the playing property, you should use the audio player action. It's in the Add Track menu, second to last.

answered Dec 11, 2019 by andersmmg (418 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.