update: player prefab
fix: pistol not firing with higher fire rate
This commit is contained in:
@@ -6,10 +6,10 @@ public class Pistol : Weapon
|
||||
public Transform spawnPosition;
|
||||
public float fireRate = 1f;
|
||||
|
||||
float currentDelay = 0;
|
||||
[SerializeField] float currentDelay = 0;
|
||||
|
||||
public override void Shoot(bool keyDown, bool keyHold) {
|
||||
if (keyDown && (fireRate == 0 || currentDelay == 1 / fireRate)) {
|
||||
if (keyDown && (fireRate == 0 || currentDelay >= 1 / fireRate)) {
|
||||
Instantiate(projectilePrefab, spawnPosition.position, spawnPosition.rotation);
|
||||
currentDelay = 0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ using UnityEngine;
|
||||
|
||||
public abstract class Weapon : MonoBehaviour
|
||||
{
|
||||
public bool isActive { get; private set; } = true;
|
||||
public bool isActive { get; private set; } = false;
|
||||
|
||||
public abstract void Shoot(bool keyDown, bool keyHold);
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ public class WeaponController : MonoBehaviour
|
||||
|
||||
void Start() {
|
||||
weapons = GetComponentsInChildren<Weapon>();
|
||||
for (int i = 0; i < weapons.Length; ++i) {
|
||||
if (i != currentWeapon) weapons[i].SetWeaponState(false);
|
||||
}
|
||||
if (weapons.Length > currentWeapon) weapons[currentWeapon].SetWeaponState(true);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
|
||||
Reference in New Issue
Block a user