Hey, I made an “ammo” counter for my gun script, how ever it keeps setting it to 100 even though I tell it to become 10, and when I click to Fire the ammo then gets messed up.
Code:
var BulletSpawn : Transform;
var Bullet : GameObject;
var Ammo = 10 ;
function Start () {
}
function Update () {
if(Input.GetButtonDown("Fire1")) {
Instantiate(Bullet, BulletSpawn.transform.position, BulletSpawn.transform.rotation);
Ammo -- ;
}
}
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), "Ammo : " + Ammo);
}
Picture:
Before:

After:
