my gun wont reload right, here is my script:
var projectile : Rigidbody;
var canshoot = 1;
var clone : Rigidbody;
var reloading = 0;
var ammo = 32;
function Update () {
if (Input.GetKey("space")) {
if (canshoot == 1)
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.left * 60);
canshoot = 0;
Invoke("CanShoot",0.1);
ammo -= 1;
}
if (ammo == 0){
reloading = 1;
canshoot = 0;
Invoke ("Reload",1);
}
}
function CanShoot() {
if (reloading == 0)
canshoot = 1;
}
function Reload () {
ammo = 32;
reloading = 0;
canshoot = 1;
}
the gun shoots fine for the first clip, when it runs out of ammo it tries to reload and 1 second later when its reloaded it shoots every frame not every 0.1 seconds, what did i do wrong?