Files
No-Time-To-Rest/Assets/Scripts/Player/Rifle.cs
T
KOSMOGOR f754b692e2 add: minigun
bug: minigun's mesh
2025-04-27 17:35:06 +03:00

22 lines
656 B
C#

using UnityEngine;
public class Rifle : Weapon
{
public GameObject projectilePrefab;
public Transform spawnPosition;
public float fireRate = 3f;
[SerializeField] float currentDelay = 0;
public override void Shoot(bool keyDown, bool keyHold) {
if (keyHold && (fireRate == 0 || currentDelay >= 1 / fireRate) && GameController.i.ConsumeBullet(bulletType)) {
Instantiate(projectilePrefab, spawnPosition.position, spawnPosition.rotation);
currentDelay = 0;
}
}
void Update() {
if (fireRate != 0) currentDelay = Mathf.Clamp(currentDelay += Time.deltaTime, 0, 1 / fireRate);
}
}