0 votes

Ok so I work at a space shooter and i want to restart the scene after the player gets destroyed and the explosion animation is finished but I don't want to make a separate scene with a explosion just for the player how i looked it was done on a tutorial but on the timeout signal of the timer node of the explosion i want to check if the signal for destroying the player was emitted and then restart the scene after the animation for explosion was finished. It is possible? it is a method or something capable of doing that?
Thank you in advance and sorry for bad english:).

Godot version Godot v3.2.3 stable.official
in Engine by (47 points)

2 Answers

+1 vote
Best answer

Yes it is possible. The Timer Node has a signal on the Signal Tab between the Inspector Tab called "timout". If you connect the signal to your code it execute the code if the Animation is finished. It should look like that :


I dont know if I misunderstood you. If its true you can ask me again.

by (254 points)
selected by
func _on_Timer_timeout():
   * if emited_signal_is("player_destroyed"):*

this is what i'm tring to get. Sorry for not being clear

I had the same problem. I solved it this way.

var explosion = 0

func _on_Timer_timeout():
    explosion = 1

func _on_emited_signal("player_destoyed"):
    if explosion = 1:

I dont know if thats the best way but it should work.

Thank you it worked!

+1 vote

I don't know how exacly you are organizing your animations and states, but there is a function called "yield", that should allows you do what you want.

You can use it in many ways, and you can check it here

To call a function after an animation ends, you do:

yield(get_node("AnimationPlayer"), "animation_finished")
by (16 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 Frequently asked questions and 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 [email protected] with your username.