Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Ben 39 · May 22, 2011 at 03:51 PM · loadlevelkillhealth

Load level with 0 health help.

When the players life is 0, they are taken back to the main menu. But when I restart the game from that menu the player has 0 health and stuck in a game over loop. Is there anyhing I can do to change this?

Below is the game I used.

 var health100 : Texture2D; //full health

var health95 : Texture2D; //nineteen lives left var health90 : Texture2D; //eightteen lives left var health85 : Texture2D; //seventeen lives left var health80 : Texture2D; //sixteen lives left var health75 : Texture2D; //fifteen lives left var health70 : Texture2D; //fourteen lives left var health65 : Texture2D; //thirteen lives left var health60 : Texture2D; //twelve lives left var health55 : Texture2D; //eleven lives left var health50 : Texture2D; //ten lives left var health45 : Texture2D; //nine lives left var health40 : Texture2D; //eight lives left var health35 : Texture2D; //seven lives left var health30 : Texture2D; //six lives left var health25 : Texture2D; //five lives left var health20 : Texture2D; //four lives left var health15 : Texture2D; //three lives left var health10 : Texture2D; //two lives left var health5 : Texture2D; //one lives left var health0 : Texture2D; //no lives left

static var LIVES = 21;

function Update () { switch(LIVES) { case 21: guiTexture.texture = health100; break;

      case 20:
          guiTexture.texture = health95;
          break;
          
      case 19:
          guiTexture.texture = health90;
          break;    
          
      case 18:
          guiTexture.texture = health85;
          break;
          
      case 17:
          guiTexture.texture = health80;
          break;
          
      case 16:
          guiTexture.texture = health75;
          break;
          
      case 15:
          guiTexture.texture = health70;
          break;
          
      case 14:
          guiTexture.texture = health65;
          break;    
          
      case 13:
          guiTexture.texture = health60;
          break;
          
      case 12:
          guiTexture.texture = health55;
          break;     
          
      case 11:
          guiTexture.texture = health50;
          break;
          
      case 10:
          guiTexture.texture = health45;
          break;
          
      case 9:
          guiTexture.texture = health40;
          break;
          
      case 8:
          guiTexture.texture = health35;
          break;    
          
      case 7:
          guiTexture.texture = health30;
          break;
          
      case 6:
          guiTexture.texture = health25;
          break;
          
      case 5:
          guiTexture.texture = health20;
          break;
          
      case 4:
          guiTexture.texture = health15;
          break;     
          
      case 3:
          guiTexture.texture = health10;
          break;    
          
      case 2:
          guiTexture.texture = health5;
          break;
          
      case 1:
          guiTexture.texture = health0;
          Application.LoadLevel (0);
          break;    
  }

}

Comment
Add comment · Show 1
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 Ben 39 · May 22, 2011 at 03:52 PM 0
Share

P.S sorry about my back code pasting..

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eli-Davis · May 22, 2011 at 03:56 PM

When you get to case 1, reset the health to 100. then have it load the main menu. I'd think that would work.

Comment
Add comment · Show 2 · 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 Ben 39 · May 22, 2011 at 04:21 PM 0
Share

How would I reset the script at the end?

avatar image Eli-Davis · May 22, 2011 at 05:15 PM 0
Share

LIVES =+20;

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

2 People are following this question.

avatar image avatar image

Related Questions

How to Make a "Kill Platform"? 1 Answer

PlayerHealth drops fast and wont reset 1 Answer

Death scene/screen on player Health Script Wont work! 0 Answers

How to make heart health system? 3 Answers

Lower Object Health If Collides With "Player" Tag,Lower Object Health If Collides With Player Tag 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