how to yous and in if statement

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

hi, im triying to make an gameoverscrene.
in the gameoverscreen, you can press R to respawn.
if i press R while the screen isnt visible i respawn also.

func _process(delta):
if Input.is_action_pressed(“r_respawn”):
get_tree().change_scene(“res://planets/Spatial”)

where and how do i have to write “and gameoverscreen.visible=true:” ?
cos it doesn’t work if i set it after the (“r_respawn”)

:bust_in_silhouette: Reply From: Help me please

Is it a 3d game?
If yes then have you added any camera node? For 3d games its very important to have an camera3d node. So just try adding an camera 3d node to your scene

i know that :slight_smile:

theMX89 | 2021-06-14 14:26

:bust_in_silhouette: Reply From: theMX89

it’s almost a complete 3d game. it’s a first person game, and my problem is that i want the gameoverscrene in the same scene as the game itself. the gameoverscrene is in 2d and you see it, if you die.
I have programmed that when you press r, you respawn, and when you press q, you come to the main menu. but if you press r or q, even if you are not dead yet, you respawn or you will be brought to the main menu anyway. that’s why I wanted to use “and” in the if statement, but I don’t know how to do it. so i came here.

:bust_in_silhouette: Reply From: Help me please

Got it!
You mean 2d in 3d…
Watch this video and see if you can do it https://youtu.be/37hEX3Lrc0A
Or else right click on gameoverscreen and select save branch as scene. Then you need to use

get_tree().change_scene("res://gameoverscreen.tscn")

ok, but i want that you see the 3d scene also after you die, like in minecraft.
i made also a red effect.

theMX89 | 2021-06-19 10:23

:bust_in_silhouette: Reply From: Help me please

Hi!
I exactly got your answer. You just need to change the root to node rather than spatial. Then you can simply use

gameoverscreen.show()

Just after (“r_respawn”)
This worked fine for me :slight_smile: