+1 vote

Hello, i started using godot like a week ago and im working on a simple game (obs watching tutorials on yt).

I have a Menu scene (which contains 3 buttons, Start, Option, Exit) and a World scene (which contains the Player/Monsters/Bushes etc). Selecting start will change the scene from Menu to World, if the player dies from the World to Menu. (works fine)

The problem is when i select Start button again, the player is not starting with the full HP like before.

The code is quite big so i'll use the Pastebin (i hope it's ok to do that) and some Printscreens to see how i organized the nodes.
Player script: https://pastebin.com/88UeKbdt
Player scene: https://imgur.com/a/gP8NNmZ
SceneTransition script: https://pastebin.com/7UJXyMv2
PlayerStats script: https://pastebin.com/T12XPtfW

Godot version 3.3.2
in Engine by (24 points)

1 Answer

+1 vote

You have the player stats in a singleton when you reset the scene the singleton is not doing it, so you have the old values of it, this is because the singleton is outside the general tree, you can see it in the remote tab when you click play

by (25 points)

What do you think the best solution is for that problem ? Not making the player stats as a singletone ?

Update: I fix it by setting the player health in the ready function and i think it works fine

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.