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 MaximusGuy · Jan 22, 2013 at 05:20 PM · guitexturecustomhealthbarhealth

How do I make a custom health bar?

Hi, i'm making a project with unity and I need a way to add a custom health bar to my game. When I say "custom health bar", I mean one with textures I have made myself changing every time my player takes damage. I do not wish to have a "box" for my health bar, I would like to use my own custom graphics for my health bar. Thanks!

Comment
Add comment · Show 5
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 AlucardJay · Jan 22, 2013 at 05:20 PM 0
Share

a search engine is your friend .... http://lmgtfy.com/?q=unity+health+bar

check the answer by cody.burleson here : http://answers.unity3d.com/questions/237381/to-draw-a-health-bar.html

Unity Answers is a $$anonymous$$nowledge Base, so chances are someone has already asked this question, and someone else has answered it well. Please search the title to your question before submitting a new one, thanks.

avatar image MaximusGuy · Jan 22, 2013 at 05:26 PM 0
Share

I understand, but I am having issues using my own graphics, I have already tried searching that several times, and have seen this question. I am trying to make it switch between images I've made when my player gets hurt, will the answer in there complete that?

avatar image AlucardJay · Jan 22, 2013 at 05:39 PM 0
Share

I see, most just use 2 images, foreground and background. It is absolutely possible to use multiple textures based on the current health. For example, if you are looking at : http://mastergamecraft.com/2012/10/13/create-a-playerhealth-status-indicator-for-unity-gui-part-1/

then it would be a matter of having an if-else cluster or a switch-case to change the foregroundTexture to one of your custom textures, eg :

 if ( health < 25 )
 {
     foregroundTexture = myTexture1;
 }
 else if ( health < 50 )
 {
     foregroundTexture = myTexture2;
 }
 else if ( health < 75 )
 {
     foregroundTexture = myTexture3;
 }
 else if ( health < 100 )
 {
     foregroundTexture = myTexture4;
 }
avatar image MaximusGuy · Jan 22, 2013 at 05:41 PM 0
Share

This looks good, thanks! And by the way, why didn't you post this as an answer?

avatar image AlucardJay · Jan 22, 2013 at 05:49 PM 0
Share

I consider myself lesss skilled to alot of people on this 'site, and if the question appears unanswered then maybe one of them will give a better answer (especially as this is a very fresh question). I just try and help out with the moderation que and answering the new user questions. Sometimes I find the other mods have converted my comments to answers! Anyway, hope this helps, and if this method works I shall convert to answer. Good Luck and Happy Coding =]

sorry for the google thing, there have been alot of questions lately that have been asked numerous times, but as you pointed out and I recognize they usually only deal with 2 textures.

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

The Game Over creating with audio? 1 Answer

GuiTexture above 3D objects 1 Answer

Issue with GUITexture width. 1 Answer

dragable GUI 0 Answers

How to make a camera's background be another camera's veiw 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