- Home /
Duplicate Question
ammo display javascript
i need a ammo display script, so when i shoot the gun, the ammo in the bottom left shows how much bullets i have left.
example:
23/30
you may want to have a look at some tutorials on scripting to get this
You shouldn't come here and just ask for scripts from people if you are serious at all about making a game. Google it first "Unity ammo display on gui" and you will find all kinds of examples.
Ya, we'll I'm 13 clunk47, so I think I'm doing pretty good. You are probably way better then me. And this is called unity answers.
Yes sir. It IS called Unity Answers, not Unity Script Repository. Don't get too upset. Have a look at the Unity $$anonymous$$anual and the Unity Script Reference. If you really want to get into this, As @reptilebeats explains, have a look at some Tutorials provided by Unity. These should lead you in the right direction. There is a tutorial there called "GUI Essentials" that will get you really going with GUI code. Here are some demo projects you could download and skim through as well.
Answer by Android Matt · Jul 15, 2013 at 10:51 PM
You will need two variables, one to store your max ammo and one to store the current ammo.
In order to display those you will need to use some form of GUI, e.g:
var currentAmmo: int = 30;
var totalAmmo: int = 30;
function OnGUI () {
GUI.Label (Rect (25, 25, 100, 30), currentAmmo+"/"+totalAmmo);
}
I agre with reptilebeats, tutorials would be a good place to start. There are plenty that can be found with quick Google.
Follow this Question
Related Questions
Gun Firing help? 2 Answers
How to let my gun shoot ?? 0 Answers
musket gun script is not working 3 Answers
Some issues with weapon switching and reloading? 2 Answers
crosshair scrip not working 1 Answer