How to place this sprite after the animation finishes?

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

So I have attackable grass in my Action RPG like Zelda, and I want to place a sprite of broken grass right after the breaking animation finishes. But the sprite is placed right as the animation plays. I don’t know how to make the sprite wait until the animation is done. Here’s the script:

extends Node2D

const Grass_Effect = preload(“res://Effects/GrassEffect/Broken_Attackable_Grass.tscn”)
const Grass_Pieces = preload(“res://Other/GrassPieces.tscn”)

func place_grass_pieces():
var grassPieces = Grass_Pieces.instance()
grassPieces.global_position = global_position

func create_grass_effect():
var grassEffect = Grass_Effect.instance()
grassEffect.global_position = global_position

func _on_Hurtbox_area_entered(area):
<-------------------------------- I want to put the “waiting” action here.

:bust_in_silhouette: Reply From: jgodfrey

You can do something after an animation completes by coupling coupling yield with an animation player’s animation_finished signal. Generally, that looks like this:"idle")
yield($AnimationPlayer, "animation_finished")
# --- code here executes *after* the running animation finishes...

Yea, I’ve seen that done when looking at other posts, but the animation the grass is connected to doesn’t have the Animation Player connected, only the animation :/, I’ll try this again, but I’m pretty sure I can’t use this method.

PizzaOnFire99125 | 2020-04-28 08:58