- Home /
Reset a static variable?
How can I reset a static variable with a function?
Comment
Best Answer
Answer by oliver-jones · Dec 01, 2010 at 02:25 AM
Like so:
static var Name : int = 5;
function ResetVaribales()
{
Name = 5;
}
You just call this function in your Update for example and it will reset it.
Or you can do:
static var Name : int = 5; private var NameReset : int = 5
function ResetVariables() { Name = NameReset; }
Super awesome! I searched forever for how to do this without rewriting everything and the first script you listed fixes all of my problems with trying to reset both lives and the enemy count when clicking the "play again" or "retry". I just made this a separate "reset" script that functioned during the mouse enter on those menus options and Bam, total reset prior to load. I wish I had the reputation to upvote!