0 votes

https://www.youtube.com/watch?v=UpTlc51dGhQ&list=PLyckz_-Rzq6ClGevL2fneJ5YJnMPKWa4M&index=6

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

func onbodyentered(body):
$AnimatedSprite.play("explosion")
queue
free()

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

Godot version Godot 3.3.3
in Engine by (12 points)

1 Answer

0 votes

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):
  $AnimatedSprite.play("explosion")
  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.

by (80 points)

or use the animation signal:

func onanimationfinished():
queue_free():

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.