This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

To keep it simple, my game is a platformer. I want to be able to keep track of how many times the player has died, as well as a timer from when they started so they can try and beat the game faster on the next playthrough.

When the player dies, I call get_tree().reload_current_scene() in order to reset the scene. I haven't found a way to have a variable that ticks up every single time the player dies (scene resets) and a way to keep the timer from resetting back to what it was when the scene started.

How can I do this?

Godot version 3.4.4
in Engine by (19 points)

1 Answer

+1 vote

You can use an autoload for this:
https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html

Autoloads are nodes that are automatically loaded by the SceneTree, separately from the current scene. They therefore remain when reloading the scene.

by (22,191 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.