Изменил логику перезарядки туррелей

This commit is contained in:
2026-05-17 01:32:08 +03:00
parent 394c2d6736
commit fe8ff701d2
+2 -6
View File
@@ -14,28 +14,24 @@ public class Turret : MonoBehaviour
public int Price => _price; public int Price => _price;
private void Update() private void Update()
{
if (_reloadTimer >= _reloadTime)
{ {
SpawnBullet(Vector3.forward); SpawnBullet(Vector3.forward);
SpawnBullet(Vector3.back); SpawnBullet(Vector3.back);
SpawnBullet(Vector3.left); SpawnBullet(Vector3.left);
SpawnBullet(Vector3.right); SpawnBullet(Vector3.right);
_reloadTimer = 0f;
}
_reloadTimer += Time.deltaTime; _reloadTimer += Time.deltaTime;
} }
private void SpawnBullet(Vector3 direction) private void SpawnBullet(Vector3 direction)
{ {
if (!DetectEnemy(direction)) if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
return; return;
var rot = transform.rotation; var rot = transform.rotation;
rot.SetLookRotation(direction); rot.SetLookRotation(direction);
Instantiate(_bulletPrefab, transform.position, rot, transform); Instantiate(_bulletPrefab, transform.position, rot, transform);
_reloadTimer = 0f;
} }
private bool DetectEnemy(Vector3 direction) => private bool DetectEnemy(Vector3 direction) =>