0 votes

I'm making it so that if the furnace life goes to zero the scene will reset. But my problem is that if you put a variable in a Global script, the variable will not reset if you reset the scene. Are there any better way to to this?

func _process(_delta): if Global.Furnace_Life == 0: get_tree().reload_current_scene()

Godot version v3.4.3.
in Engine by (44 points)

1 Answer

0 votes

Autoload Global script is exactly for situations of keeping variables, that You want to keep unchanged when scenes are replaced. Like difficulty level or players statistics, or graphic options or saved states of game. You should have kept furnace hp in resettable furnace script. Just leave Global out of this and your problem is gone.

by (5,651 points)

Ty for the suggestion. Yes I tried that, but I wanna use the variable in other scripts. Is there any other way of using variables in other scripts?

Why would You need to keep this variable in other scripts ? Maybe You want to have global variable maxhp, but You should keep local hp in local scripts.

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 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 webmaster@godotengine.org with your username.