Изменил спавн пули

This commit is contained in:
2026-05-19 20:14:40 +03:00
parent 893353a41c
commit 4cb295785e
2 changed files with 11 additions and 5 deletions
+8 -2
View File
@@ -1,9 +1,9 @@
using System;
using UnityEngine;
public class Turret : MonoBehaviour
{
[SerializeField] private TurretBullet _bulletPrefab;
[SerializeField] private Transform _bulletSpawnPoint;
[SerializeField] private float _reloadTime = 1f;
[SerializeField] private float _damage;
[SerializeField] private float _distance = 3f;
@@ -15,6 +15,12 @@ public class Turret : MonoBehaviour
public float Damage => _damage;
public float Distance => _distance;
private void Start()
{
if (_bulletSpawnPoint == null)
_bulletSpawnPoint = transform;
}
private void Update()
{
SpawnBullet(Vector3.forward);
@@ -30,7 +36,7 @@ public class Turret : MonoBehaviour
if (_reloadTimer < _reloadTime || !DetectEnemy(direction))
return;
_bulletPrefab.Spawn(this, direction);
_bulletPrefab.Spawn(this, _bulletSpawnPoint.position, direction);
_reloadTimer = 0f;
}