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 12 · Mar 23, 2011 at 12:09 AM · guiupdatepickupammo

Why is this Pickup Script Not Updating my GUI for ammo

I've made some changes to the FPS tutorial's Pickup script only I can't figure out why it's not updating my GUI text. My Health bar works great, I pick up a health box and it adds to my health bar so that one is fine.

My Rockets were working but now they're not.

My Ammo for my Shotgun is working but I can't seem to get it to apply an ammo pickup when I run over the ammo box I set up.

And my grenade pickup I've never been able to get to work!!

And my Machine gun was working before too by for some reason it's not any more. Man this stuff drives me buggy! Here is my Pickup Script. If you need to see my individual weapon's scripts let me know and I'll re- edit this with those scripts.

enum PickupType { Health = 0, Rocket = 1, Ammo = 20, Shells = 10, Grenades = 20 } var pickupType = PickupType.Health; var amount = 20; var sound : AudioClip;

private var used = false;

function ApplyPickup (player : FPSPlayer) { if (pickupType == PickupType.Health) { if (player.hitPoints >= player.maximumHitPoints) return false;

     player.hitPoints += amount;
     player.hitPoints = Mathf.Min(player.hitPoints, player.maximumHitPoints);
 } 


 else if (pickupType == PickupType.Rocket) {
     var launcher : RocketLauncher = player.GetComponentInChildren(RocketLauncher);
     if (launcher)
         launcher.ammoCount += amount;
 }

 else if (pickupType == PickupType.Ammo) {
         var ammo : MachineGun = player.GetComponentInChildren(MachineGun);
         if (ammo)
         ammo.bulletsPerClip += amount;
 }

 else if (pickupType == PickupType.Shells) {
         var Shells : Shotgun = player.GetComponentInChildren(Shotgun);
         if (Shells)
         Shells.bulletsPerClip += amount;
 }

 else if (pickupType == PickupType.Grenades) {
         var Grenades : MissileLauncher = player.GetComponentInChildren(MissileLauncher);
         if (Grenades)
         Grenades.ammoCount += amount;
 }

             return true;

}

function OnTriggerEnter (col : Collider) { var player : FPSPlayer = col.GetComponent(FPSPlayer);

 //* Make sure we are running into a player
 //* prevent picking up the trigger twice, because destruction
 //  might be delayed until the animation has finnished
 if (used || player == null)
     return;

 if (!ApplyPickup (player))
     return;
 used = true;

 // Play sound
 if (sound)
     AudioSource.PlayClipAtPoint(sound, transform.position);

 // If there is an animation attached.
 // Play it.
 if (animation && animation.clip) {
     animation.Play();
     Destroy(gameObject, animation.clip.length);
 } else {
     Destroy(gameObject);
 }

}

// Auto setup the pickup function Reset () { if (collider == null)
gameObject.AddComponent(BoxCollider); collider.isTrigger = true; }

Comment
Add comment · Show 2
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 AngryOldMan · Mar 23, 2011 at 12:17 AM 0
Share

You havn't actually asked a question you have just listed things that don't work with your game. Try debug logging it, try saving severzl versions of the project and keeping a developer diary so you know what you have changed and when things broke. Also if you don't ask a question how the hell are you going to get an answer?

avatar image Michael 12 · Mar 23, 2011 at 12:36 AM 0
Share

Well I don't know anything about the stuff yur talking about in that first part, I'm just not that technical $$anonymous$$ded, 2nd my codeing knowledge is not that great. So I thought I was giving as much information about my problems as I can, I even mentioned that if more information was required I'd place it in an update.

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

GUI player menu is not updating values (score, exp, HPs) 1 Answer

Script variables resetting on play 0 Answers

GUI text like GTA 2 Answers

GUI Final Scene/ Item Pickup 0 Answers

GUI dependent on an int variable 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