I think something missing in the Fire() function.
Even there is no ammo the script continue to calculate the Ray and shoot robot.
I modify like this to avoid this.
protected void Fire() {
if (ammo.HasAmmo(tag)) {
GetComponent<AudioSource>().PlayOneShot(liveFire);
ammo.ConsumeAmmo(tag);
} else {
GetComponent<AudioSource>().PlayOneShot(dryFire);
}
GetComponentInChildren<Animator>().Play("Fire");
//if there is no ammo don't shoot
if (!ammo.HasAmmo (tag))
return;
Ray ray = Camera.main.ViewportPointToRay(new
Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
if (Physics.Raycast(ray, out hit, range)) {
processHit(hit.collider.gameObject);
}
}