How do I do a game over screen?

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

Below are a couple of the things I’ve tried to achieve this. I gave the gave over screen a control node with a menu that is defaulted to not being visible. How can I achieve this?

Method 1

#player
signal death_screen
if health >= 0: 
	queue_free()
	emit_signal(death_screen)
#death 
func _on_player_death_screen():
visible = true
pass 

Can’t play game at all. It crashes.

Method 2

if health >= 0: 
	queue_free()
	$death.visible = true

Game plays but crashes when player takes damage. Also has Node not found error in debugger.

:bust_in_silhouette: Reply From: Zylann

For method 1, you should emit your signal with quotes:

emit_signal("death_screen")

For method 2, you are implying that the "death" node is child of your player, which it probably isn’t. Check that the path is valid. What is the hierarchy of your scene?

Thank you I can’t believe I forgot the quotes lol. Thanks.

sumguy05 | 2019-02-17 08:14