I can check if a signal was emmited

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

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:).

:bust_in_silhouette: Reply From: Weslley Al

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")
:bust_in_silhouette: Reply From: Bot7

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.

func _on_Timer_timeout():
   * if emited_signal_is("player_destroyed"):*

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

Shortanel | 2021-02-05 18:29

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.

Bot7 | 2021-02-05 23:06

Thank you it worked!

Shortanel | 2021-02-06 01:09