Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by oliverdjc · Sep 17, 2012 at 12:35 AM · menugameovermain

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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");
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kmeboe · Sep 17, 2012 at 07:20 PM 0
Share

+1 for amazing function name!

avatar image taters22 · Jun 13, 2014 at 07:33 AM 0
Share

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.

avatar image Galactic_CakeYT taters22 · Jun 11, 2020 at 05:09 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges