My game runs and I don’t get any errors of any kind, but I can’t seem to get my reloading function to work. Nothing happens when I press the “r” key. I think it has to do with me calling the reload function in a spot the game can’t detect, but I googled my problem dozens of times and I can’t come up with why it wouldn’t work calling it in the Update. Any advice/suggestions would be appreciated.
var speed = 10;
var maxbullets : int = 6;
var totalBullets: int = 12;
var reloadtime: int = 2;
var transfer : int = 6 - maxbullets;
function Update() {
Fire();
Reload();
}
function Fire() {
if (maxbullets > 0);
if(Input.GetButtonDown("Fire1"))
{
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3 (0, 0, speed));
Destroy(clone.gameObject, .25);
maxbullets -= 1;
GameObject.Find("BulletCount").guiText.text = ""+maxbullets;
}
}
function Reload() {
if(totalBullets > 0);
if (transfer > totalBullets) { transfer = totalBullets; }
if(Input.GetKeyDown("r"))
yield WaitForSeconds (reloadtime);
animation.Play("RevolverReloadAnimation");
{
maxbullets += transfer;
totalBullets -= transfer;
GameObject.Find("TotalBullets").guiText.text = ""+totalBullets;
}
}
Thanks!