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
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.