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 james 1 · Jun 30, 2010 at 08:01 PM · pickupammofpstutorial

ammo cache pickup

ok so im following the unity fps tutorial and everythings fine and dandy but i want to put in ammo crates. therers already health pickups but i want to know if theres any script that allows the player to pickup more ammo....and play a sound

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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by 0V3RWR173D · Jun 30, 2010 at 10:47 PM

First of all, you will need the model for the crates (or just put a cube with a color or texture on it). The fps tutorial files already comes with a pickup javascript but that does not include a part for the machine gun. You could add a part for the machine gun but that means that you will have to modify the machine gun's script. At the top line of the pickup it shows this:

enum PickupType { Health = 0, Rocket = 1 }

Add to it so that you get this:

enum PickupType { Health = 0, Rocket = 1, Ammo = 20 }

(you can change the "20" to any amount that you want to add to the machine gun)

Under the part of the script that says this:

function ApplyPickup (player : FPSPlayer)

Put this:

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

(add it before it says "return true;")

Where it says bulletsPerClip, you are going to have to modify the machine gun script and change that to your other variable.

Now you will not be able to have separate clips for your machine gun, it will just be a certain amount that you have as a total. (without changing the machine gun script it will just change the amount that each clip holds by adding 20)

I am still working on a way to modify the machine gun script so that it is only the total and there are no clips.

I hope that this has helped you. Please tell me if I gave you the wrong information and you want to know something different.

Comment
Add comment · Show 4 · 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 Michael 12 · Feb 21, 2011 at 08:13 PM 0
Share

Sounds cool, I've been trying to do the same thing, I made a nice crate model for my Rockets pickup, but having touble trying to get the script from that same tutorial to do the same, Worked well when I added my own health box though.

I'm an artist not a coder so Java script kind of makes me want to go out into a vacant field and let out some primal screams lol

avatar image Michael 12 · Feb 21, 2011 at 08:20 PM 0
Share

Actually that worked fine for my Rockets, sorry, just tested it out and it even updated my Rockets GUI which I wasn't expecting as i thought maybe I was missing something, Wicked!! Thanks man that's the best piece of advice I think I'vve ever found on here, you ROC$$anonymous$$!!

avatar image user-11096 (google) · Apr 21, 2011 at 04:46 PM 0
Share

Well there is a problem i just want to add another clip and not get extra bullets for every clip. I got 30 bullets a clip, then i pick it up and and when i reload i get even more bullets, i get 50 bullets. Change it so you grab a clip ins$$anonymous$$d of more bullets a clip.

avatar image Michael 12 · May 11, 2011 at 04:29 PM 0
Share

Even better still change it so you can pick up a certain amount of "Clips" that way your clips get added to your ammo that way when a clip runs out you have to reaload... now how the Frack is that done?? I've been asking and asking and searching and searching with no answers to that??

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

eating candy, spitting it out. 1 Answer

Script not working at ALL 0 Answers

Help Needed with Shotgun script (SOLVED) 0 Answers

how do you pick up ammo by clip amount 1 Answer

What is going on with this pickUp Script? 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