Changing scenes at game over still running previous scenes.

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

When my player dies, I try to load my gameover scene.

func hurtplayer(power):
print(“hit player with power:”+str(power))
$“/root/global”.playerhealth -= power
if($“/root/global”.playerhealth < 1):
print(“player dead”)
global.play_sound(“hurtplayer”, false, global_transform.origin)
print(“coming out of hurtplayer”)

It does NOT load this even though it exists and works. It prints player dead and then apparently skips starting gameover.tscn, because it immediately prints “coming out of hurtplayer”.


The gameover scene works when i try it by itself. And I copied its path to put into the get_tree so its definitely right…

Is there something wrong in gameover scene:

extends Control

func _ready():
pass # Replace with function body.

func _on_Button_pressed():
pass # Replace with function body.

It is just simple and works on its own.

change__scene returns an Error-code - have you made sure it’s OK (i.e. 0)?

njamster | 2020-05-04 11:38