0 votes

Hello, so I have a separate code for this question that increases difficulty (mob spawn and speed among other things.) And the two are unrelated, because it was just easier for me to code. The code in question is as simple as:

func onDiffTimer1_timeout():
GlobalSignals.level += 1
$Level1.text = "Level: " + str(GlobalSignals.level)

With the (autoloaded) GlobalSignals variable "level" as 1.

var level = 1

When playing it works great and I made the "DiffTimer1" match the wait time (25 seconds) of the previous progressive difficulty scripting I mentioned earlier, but that isn't important. While playing, The label goes from "Level 1" then 25 seconds later "Level 2" , etc. perfectly fine every 25 seconds, but after dying, going back to main screen, and hitting to start to begin a new game, the level text stays as "Level: " and then whatever the previous game ended on. If you're curious I do have the $DiffTimer1.start() and $DiffTimer1.stop() at both my newgame and gameover functions.

in Engine by (53 points)

Well that makes sense... your autoloaded scene is forever in the bg, and so the variable sticks.

Not sure that's the best practice, but I'd suggest adding a resetgameglobals() function, which init all the relevant values that you want to init on a new game.

1 Answer

0 votes
Best answer

Hello, I'm new to Godot,
Try to do: when you die, in that function, write GlobalSignals.level = 1

by (238 points)
selected by
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 webmaster@godotengine.org with your username.