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 /
This question was closed Dec 02, 2014 at 01:24 PM by unimechanic for the following reason:

Duplicate Question

avatar image
0
Question by Valon · Feb 08, 2014 at 05:45 PM · gui-problem

Texture2D width

Hello,

I'm programming HP bar for the bad guys of my little game and I've run across two problems that I can't solve by myself or by googling. I hope you'll be able to help me. It might be important to know that my hp bars appear on the top of the screen kinda like in Diablo and not above their head.

First problem :

When I change the bar width it moves to the left for no apparement reason. This make it go outside of the frame (which is also a Texture2D but it doesn't move).

Second problems :

My HP bars show up when an enemy it being hit and disapear after a while if nothing happened to this enemy. The big problem I have is how do I switch bar, because if there is two enemies I want the bars to switch depending on who I hit. Right now they just appear on top of each other. So I'd like to hide one without destroying it every time this happens so I only have one bar on the screen. The bars have to keep the information once they are hidden obviously.

Here is the GUI part of the script attached to each bad guy :

 void OnGUI() {
         
         if (hasBeenhit == true && CoolDownGUI == true) {
             FramePosition.x = (Screen.width - FramePosition.width) / 2;
             FramePosition.width = Screen.width * 0.4f;
             GUI.DrawTexture (FramePosition, Frame);
             HealthBarPosition.x = FramePosition.x + FramePosition.width * OffsetHori;
             HealthBarPosition.y = FramePosition.y + FramePosition.height * OffsetVerti;
             HealthBarPosition.width = FramePosition.width * healthPourcent;
             GUI.DrawTexture (HealthBarPosition, HealthBar);
             
         }
     }
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

  • Sort: 
avatar image
0

Answer by unimechanic · Dec 02, 2014 at 01:23 PM

http://answers.unity3d.com/questions/11892/how-would-you-make-an-energy-bar-loading-progress.html

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

Follow this Question

Answers Answers and Comments

19 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Compass refuses to find North 1 Answer

Circle GUI rough edges 1 Answer

GUI Screen Size 1 Answer

GUIText appears/disappears problem 0 Answers

OUYA Iap with OnCollisionEnter 0 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