Every time I get game over I have to exit out of the game completely

Godot Version

4.2.1

Question


every time my character dies it goes back to the play/quit screen, but whenever I click play it just flashes the game screen and then immediately goes back to the play/quit screen again and the only way to get it to stop doing this is to close the game completely and reopen it. any ideas?

try to debug it, add print("event_name") to check if the buttons are configured correctly. Your screenshot is not enough to recognize the error.

Ok, hold on.

and check the warnings:
Bildschirmfoto 2023-12-24 um 22.12.40


This is what the debugger says. Idk how to print event name without an error saying identifier expected at the line.

The warnings are not critical, do what it says if the warnings bother you. (rename to _delta)


example debug via print

func _ready():
    print("main -> ready")
    # more code
    # .......

or check the docs, use breakpoint

breakpoints don’t seem to help. All they do is give me a grey screen.

I’m doing this from a youtube tutorial with only one minor edit. this error started happening before the edit though.

Hard to say what it could be, can you compress the project with zip and share it on google drive for example? No zip file can be uploaded here in the forum.

yes, it’ just a sample project anyway.

Your link is not released for everyone, but I have requested it :slight_smile:

try this link
https://drive.google.com/drive/folders/1x_EwvRkF4jqqPYJmE86KORKwhnYffWJU?usp=sharing

because

	if Game.playerHP <= 0:
		print("Game.playerHP <= 0")
		queue_free()
		get_tree().change_scene_to_file("res://main.tscn")

in Player.gd, and must ‘reset’ Game.playerHP

how do I reset it though?

Game.playerHP = 10

maybe here

	if Game.playerHP <= 0:
		print("Game.playerHP <= 0")
		Game.playerHP = 10
		queue_free()
		get_tree().change_scene_to_file("res://main.tscn")
1 Like

That fixed it, thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.