I have ammo counter, and i have question in script “can i do nothing?”
here is script:
var fireInterval = 0.5;
var projectile : Rigidbody;
var speed = 10;
var ammo = 10;
var targetGuitext : GUIText;
private var nextFire;
function Start() {
nextFire = Time.time + fireInterval;
targetGuitext.text = "Ammo: "+ammo.ToString();
}
function Update () {
if (Input.GetMouseButton(0) && Time.time > nextFire) {
nextFire = Time.time + fireInterval;
ammo -= 1;
targetGuitext.text = "Ammo: "+ammo.ToString();
if (ammo <=10)
{
fire();
}
else
{
//DO NOTHING?
}
if(ammo <= 0)
{
targetGuitext.text = "Empty ammo";
}
}
}
function fire() {
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
Destroy (clone.gameObject, 5);
audio.Play();
}
please help