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
0
Question by Dummy7307 · Mar 29, 2011 at 06:30 PM · guidamageprogress-barhealth

need help with GUI healthbar

I have a want a healthbar in my game but i dont now how to make it can you plz help me. the health script is:

var health = 100.0; var dieDuration = 0;

function ApplyDamage( amount : float ) {

health -= amount;

if (health < 1) { Die(); } else { // <- (play "hurt" animation & sound here) }

}

function Die() {

// <- (play "die" animation & sound)

yield WaitForSeconds( dieDuration );

Application.LoadLevel(Application.loadedLevel);

}

and the damage script is:

var damage = 10;

function OnTriggerEnter (hit : Collider) {

if(hit.gameObject){

   hit.gameObject.BroadcastMessage("ApplyDamage", 
                                        damage, 
          SendMessageOptions.DontRequireReceiver);

}

}

I want a green healthbar that change to yellow when my character have 50 health and that change to red when the character have 15 health left.

Thx // Dummy7307

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 jahroy · Oct 20, 2011 at 07:56 AM 0
Share

It would be much easier to help if you format your code...

All you have to do is select the text that is code and click the button that looks like ones and zeros.

Unformatted code makes baby Jesus cry.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AngryOldMan · Mar 29, 2011 at 06:38 PM

What a relevant name. There is already around 50 questions eg. this on this site with an answer that explains exactly what you want to do not to mention a butt load of tutorials that pop up if you use this magical search engine called google. Start off with some GUI literature to get you started you could also look at this GUI Guide but most of all you can research a question before asking it. The fact that there is this many and you have failed to find any shows that you really don't have two stones about you to look for an answer.

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 sam32x · Oct 20, 2011 at 07:17 AM 0
Share

hi, i was trying to figure out how to make a healthbar. i found this.

  1. i searched on google and found nothing.

  2. your "this" link doesnt work

  3. i already read the script reference for gui

avatar image timsk · Oct 20, 2011 at 09:50 AM 0
Share

Google: GUI Healthbar Unity

Guide to google

Don't shoot down good answers, he was merely pointing out that you should try to help yourself before you ask others to help you.

P.S. Please don't tell us my first link doesn't help, on the results are links to a youtube step by step tutorial on what you need.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Health Bar Only For Falling Damage 2 Answers

Health Bar Centering 4 Answers

Creating a Lifebar with simple GUI in C# 3 Answers

2D GUI Group moving with players. 1 Answer

Inverse health bar 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