public override void UseWeapon() { //If we're not reloading if (!m_reloading) { //Reduce the shot interval timer m_shotIntervalTimer -= Time.time - m_lastCountOfTime; //Switching weapons stalls the reload timer, remembering the time we allows us to maintain //reload time //If the shot interval timer reaches 0 (or less) and we have ammo in our clip if (m_shotIntervalTimer <= 0 && m_clipAmmo > 0) { //Fire! Projectile proj = m_objectPool.GetFreeObject(); proj.gameObject.SetActive(true); proj.gameObject.transform.position = m_fireAid.position; //Mostly for non-symmetrical objects, make them face the right way proj.gameObject.transform.rotation = Quaternion.LookRotation(m_fireAid.forward); proj.GetComponent <Rigidbody>().velocity = m_fireAid.forward * m_fireVelocity; //Reduce the clip ammo m_clipAmmo--; //If we've run out of ammo, and have ammo left, start reloading if (m_clipAmmo == 0 && m_totalAmmo > 0) { m_reloading = true; } //If we don't have ammo left else if (m_totalAmmo <= 0 && m_clipAmmo == 0) { //Get rid of the gun? Make clicking sounds? } m_shotIntervalTimer = m_shotInterval; } } else { m_timerReload -= Time.time - m_lastCountOfTime; if (m_timerReload <= 0) { //Reload! m_reloading = false; Reload(); m_timerReload = m_reloadTime; } } m_lastCountOfTime = Time.time; }