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
1
Question by Daniel-Talis · Aug 23, 2011 at 10:30 AM · progress-barhealth

Lifebar Help

Hi, I have created a lifebar which decreases in increments when a Healthfield is entered and a trigger is activated by the Player. It works well but I cannot understand how to load a new scene when 3 negative increments have been reached. Can anyone help on this? Here is my current code for the Healthfield..

 var Hurtbox: boolean = false;
 
 function OnTriggerEnter(other: Collider){
 if(other.gameObject.tag == ("Player")){
 if(Hurtbox && LifeBar.Health >= 0){
 LifeBar.Health--;
 }
 else if(!Hurtbox && LifeBar.Health<=2){
 LifeBar.Health++;
 }
 //Destroy(gameObject);
     }
 }
Comment
Add comment · Show 4
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 Rennat · Aug 23, 2011 at 07:18 PM 0
Share

Where are you setting Hurtbox to true? also what is LifeBar? It sounds like you have a simple problem but you've got some confusing bits. help us help you :D

avatar image Daniel-Talis · Aug 23, 2011 at 08:12 PM 0
Share

Rennat, Hi, a Lifebar is the same as a Healthbar. Blocks of color that increase or decrease on collision. The video links posted by HTH_mrsnake are in the right direction I think but I'm not sure how insert a check into the above code. I need to know when there is no Health left so I can then switch levels with.. Application.LoadLevel(myLevel); Thanks.

avatar image Rennat · Aug 23, 2011 at 08:41 PM 0
Share

:) What I meant was when you type LifeBar are you working with a class? Where is that class defined?

avatar image Daniel-Talis · Aug 23, 2011 at 10:11 PM 0
Share

It's defined in the Lifebar script which builds the shape of the Lifebar and calls images to have it appear onscreen. The above code is placed on a collision object. The Lifebar script is basically..

static var Health : int = 3; var bgImage : Texture2D; // background image that is 256 x 32 var fgImage : Texture2D; // foreground image that is 256 x 32 var OutlineImage : Texture2D; // Outline image that is 256 x 32

function OnGUI () {...

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Rush-Rage-Games · Aug 23, 2011 at 05:34 PM

Try these 2 videos:

http://www.unity3dstudent.com/2010/09/beginner-b20-if-statements-and-booleans/

http://www.unity3dstudent.com/2010/07/beginner-b16-switching-scenes/

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Basic Health Bar Display Problem 1 Answer

Health Bar to Render On Top 2 Answers

Healthbar Energy Bar and MiniMaps? 0 Answers

need help with GUI healthbar 1 Answer

Need help with health script 2 Answers


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