I need to reset a level at game over.
When I use Application.LoadLevel() I get unexpected results… it doesn’t reset all my variables.
Where should they be placed to reset them, in Start() or Awake()?
I need to reset a level at game over.
When I use Application.LoadLevel() I get unexpected results… it doesn’t reset all my variables.
Where should they be placed to reset them, in Start() or Awake()?
Static variables aren’t reset, so you need to set them manually.
–Eric
Where should they be reset, in update()?
And are all non-static variables reset, whether then are in Start() or Awake()? What about exposed variables?
Thanks!
They should be reset when you want to restart the level.
Yes, and Start() or Awake() isn’t relevant.
–Eric
But does the code in Awake() get called when you use Application.LoadLevel() to reload an existing level? I’m unclear on that.
Unity wouldn’t work very well if it didn’t. ![]()
–Eric
Well, that’s what I thought.
So I assume as long as I initialize my static variables in Awake(), they should reset nicely upon resetting the level.
Is that a feature or a bug? Aren t they supposed to be reset?