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 Michael 16 · May 11, 2011 at 03:06 PM · delayresetammoweapons

reset delay bar and and ammo

I make a third person game and I created in the game health, energy and delay bars based on this question. I edited a bit the code so it will be fit to my game (bar for each weapon and time to fill each bar) and the bars are seeing all the time.

In the question I used for help, asked about how to reset the bar but I try to do wat the answed say and it don't works in my game.

Here is parts my code (the code is very long and you don't need to see all of it...):

//2D bars
 var basicSize : Vector2 = new Vector2(150,20);
 var otherSize : Vector2 = new Vector2(100,10);
 //health
 var healthBarDisplay : float = 100;
 var healthPos : Vector2 = new Vector2(130,60);
 var healthBarEmpty : Texture2D;
 var healthBarFull : Texture2D;
 //energy
 var energyBarDisplay : float = 100;
 var energyPos : Vector2 = new Vector2(130,85);
 var energyBarEmpty : Texture2D;
 var energyBarFull : Texture2D;
 //bombs
 var bombBarDisplay : float = 0;
 var bombPos : Vector2 = new Vector2(80,110);
 var bombBarEmpty : Texture2D;
 var bombBarFull : Texture2D;

there are 2 more weapon based like the bombs

energyBarDisplay += Time.time * 0.0002;
     energyBarDisplay = Mathf.Clamp01(energyBarDisplay);
     bombBarDisplay += Time.time * 0.0015;
     bombBarDisplay = Mathf.Clamp01(bombBarDisplay);
     teleBarDisplay += Time.time * 0.0015;
     teleBarDisplay = Mathf.Clamp01(teleBarDisplay);
     rocketBarDisplay += Time.time * 0.0002;
     rocketBarDisplay = Mathf.Clamp01(rocketBarDisplay);

what i did for reset:

function Explode ()
 {
     if (bombUse)
     {
         animation.Play("RockExp");
         var expEffect1 = Instantiate(bombEffect1, GameObject.Find("spawnPointA").transform.position, transform.rotation);
         yield WaitForSeconds(0.5);
         var expEffect2 = Instantiate(bombEffect2, GameObject.Find("spawnPointA").transform.position, transform.rotation);
         var ballExp = Instantiate(bombs, GameObject.Find("spawnPointA").transform.position, Quaternion.identity);
         ballExp.gameObject.tag = "CharacterProjectile";
         ballExp.rigidbody.AddForce(transform.forward * 10000);
         bombBarDisplay = 0.0f;
         //for delay
         bombUse = false;
         yield WaitForSeconds(5.0);
         bombUse = true;
     }
 }

to make the bars:

//bombs
     // draw the background:
     GUI.BeginGroup (new Rect (bombPos.x, bombPos.y, otherSize.x, otherSize.y));
     GUI.Box (Rect (0,0, otherSize.x, otherSize.y),bombBarEmpty);
     // draw the filled-in part:
     GUI.BeginGroup (new Rect (0, 0, otherSize.x * bombBarDisplay, otherSize.y));
     GUI.Box (Rect (0,0, otherSize.x, otherSize.y),bombBarFull);
     GUI.EndGroup ();
     GUI.EndGroup ();

the problem is when I use the weapon and the delay works (there is a delay) the bar needs to show on how much time I will be able to use the weapon again, When I use it the bar reset but it filled again in notime (it flashing with the empty bar). how I can reset the bars?

Another question I want to ask is how to show by numers the bullets I have, show the ammo?

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

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

No one has followed this question yet.

Related Questions

Forced player reset not being delayed 1 Answer

Can Someone Tell Me Why This Isn't Working? 2 Answers

How to reset health/energy/progress bars and how to show the ammo in numbers? 1 Answer

Adding a delay for weapon switching 1 Answer

My automatic gun don't work help! 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