- Home /
How to get back to the main menu when dead?
Ok so i need some help.
When i die in my game, how do i make it so it goes back to the main menu?
And where would i add this code to?
Answer by save · Sep 17, 2012 at 12:40 AM
The most reasonable place to put it is where the code for dying is.
Application.LoadLevel("MainMenu");
If you have several ways of dying (hard to tell without any code samples or explanation):
if (health<=0) {
ShitHitsFan();
}
function ShitHitsFan () {
Application.LoadLevel("MainMenu");
}
this is Great, it helped me out too! i know this is kinda late(like 2 years), but i have a hide cursor in my fps and when start in the main menu everything works fine. and in game its fine. but when i die and re-spawn the cursor is still hidden in the main menu(so i cant start the game again). if your still here 2 years later, i could really use your help... or anyone's help really.
Eh, 6 years late, not too bad, basically you can use a bool, and use the function
Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
and if the player is in the menu disable it something like
if(StopBeingADumbass == true) { Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
CursingIsBad = false; }
I am still new to Unity, but I think this code should work
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Main Menu Problem 0 Answers
Main Menu Button Help! 1 Answer
Quality-Settings Selections in scripting 1 Answer
How do I make a GameOver script? 1 Answer