how to make fireball explode using body_entered function

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

i have followed this youtube tutorial but i wanted to add an explosion upon the fireball contact with the wall

func _on_body_entered(body):

i have implemented this code but it doesn’t work can anybody help me?

:bust_in_silhouette: Reply From: TTF DPC

You are not giving the animated sprite enough time to play the animation. Because in the frame when you say that the animation should play, the object deletes itself and with it the animated sprite.

Try this:

func on body enter (body):
  yield(get_tree().create_timer(animation_lenght), "timeout")
  queue free()

animation_lenght is the length of your animation, which you have to find out yourself.

Sorry if I made mistakes, my English isn´t very good.

or use the animation signal:

func on_animation_finished():

umma | 2021-09-05 23:01