To fix this bug (YouTube Video), I must make sure that the die() function of the player script only gets executed once and not multiple times at once.
This is the die() function that must not execute multiple times at once:
func die():
print ("DIE!: ", stepify(dieTimer, 0.01), " / ", dieTime)
alive = false
if alive == false:
speed = 0; jumpHeight = 0
$JumpSound.volume_db = -80
if ($DeathSound.playing == false):
$DeathSound.play()
if dieTimer == dieTime or dieTimer > dieTime:
# warning-ignore:return_value_discarded
get_tree().reload_current_scene()
How do I make sure that the function only gets executed one time at a time?