• 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 /
This question was closed Jul 16, 2013 at 08:05 AM by AlucardJay for the following reason:

Duplicate Question

avatar image
-1
Question by ReflexGames · Jul 15, 2013 at 09:59 PM · javascriptfpsgunammo

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

Comment
Add comment · Show 5
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 reptilebeats · Jul 15, 2013 at 10:01 PM 0
Share

you may want to have a look at some tutorials on scripting to get this

avatar image clunk47 · Jul 16, 2013 at 04:06 AM 0
Share

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.

avatar image ReflexGames · Jul 16, 2013 at 05:09 AM 0
Share

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.

avatar image clunk47 · Jul 16, 2013 at 06:59 PM 0
Share

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.

avatar image ReflexGames · Jul 17, 2013 at 01:21 AM 0
Share

Sorry for kinda freaking out... :(

1 Reply

  • Sort: 
avatar image
2

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.

Comment
Add comment · 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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how do i attach a gun to my character 2 Answers

ammo count 1 Answer

Script not working at ALL 0 Answers

Is there a script out there that actully works for shooting bullets? 2 Answers

Need coding help with fps 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges