- Home /
How to I relaunch the application via key press?
So I used static variables for ammo in my game. When you die, it takes you to a game over scene and then escape takes you back to the menu. When you press play again, you still have the same ammo as before which is not ideal because it's a survival arena kinda game. I want to make it so when you die, the game over scene comes (heres the part I need help with) insted of just loading the menu scene (which doesn't reset the static variables) I want to make it so when your in the game over scene and press escape, it relaunches the .exe entirly so if you do that, it will load again and bring you to the main menu (any questions just comment) Thanks!
Answer by FortisVenaliter · Apr 07, 2017 at 04:07 PM
If they are static, why not just initialize the ammo variables to their proper values when you click on "New Game" from the main menu before you change the scene?
StaticClass.staticVariable = 10;
Not sure how else to explain it... If you've written the code to switch scenes and decrement the ammo, it should be pretty straightforward...
Your answer
![](https://koobas.hobune.stream/wayback/20220612114923im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Which of the Two is Better?? 2 Answers
Faster alternative to GetComponentInParent() method? 1 Answer
How can I adjust a different touch spots on the object 0 Answers