Skip to content
Snippets Groups Projects
Commit 02b2690d authored by Hanif Muhammad Zhafran's avatar Hanif Muhammad Zhafran
Browse files

fix: fix shotgun rapid firing

parent e6fba41c
Branches
Tags
No related merge requests found
...@@ -12,7 +12,7 @@ public class GunSystemMobs : MonoBehaviour ...@@ -12,7 +12,7 @@ public class GunSystemMobs : MonoBehaviour
public int magazineSize, bulletsPerTap, baseDamage, damage; public int magazineSize, bulletsPerTap, baseDamage, damage;
int bulletsLeft, bulletsShot; int bulletsLeft, bulletsShot;
bool shooting, readyToShoot, reloading; bool readyToShoot, reloading;
// Refs // Refs
public Transform attackPoint; public Transform attackPoint;
...@@ -90,7 +90,6 @@ public class GunSystemMobs : MonoBehaviour ...@@ -90,7 +90,6 @@ public class GunSystemMobs : MonoBehaviour
PlayOutOfAmmo(); PlayOutOfAmmo();
Reload(); Reload();
} else if (!reloading && readyToShoot) { } else if (!reloading && readyToShoot) {
Vector3 direction = attackPoint.transform.forward; Vector3 direction = attackPoint.transform.forward;
if (ShootingMultipleAtOnce) if (ShootingMultipleAtOnce)
{ {
...@@ -118,15 +117,15 @@ public class GunSystemMobs : MonoBehaviour ...@@ -118,15 +117,15 @@ public class GunSystemMobs : MonoBehaviour
StartCoroutine(HideMuzzleFlash()); StartCoroutine(HideMuzzleFlash());
bulletsShot--; bulletsShot--;
if (bulletsShot == 0) if (bulletsShot <= 0)
{ {
bulletsLeft--; bulletsLeft--;
PlayShootSound(); PlayShootSound();
readyToShoot = false; readyToShoot = false;
bulletsShot = bulletsPerTap; bulletsShot = bulletsPerTap;
Invoke("ResetShot", timeBetweenShooting);
} }
Invoke("ResetShot", timeBetweenShooting);
if (bulletsShot > 0 && bulletsLeft > 0) if (bulletsShot > 0 && bulletsLeft > 0)
Invoke("Shoot", timeBetweenShots); Invoke("Shoot", timeBetweenShots);
...@@ -149,4 +148,9 @@ public class GunSystemMobs : MonoBehaviour ...@@ -149,4 +148,9 @@ public class GunSystemMobs : MonoBehaviour
{ {
readyToShoot = true; readyToShoot = true;
} }
public bool IsReloading()
{
return reloading;
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment