From 06ba27da728bd2506f1cace4a8724a10891b148f Mon Sep 17 00:00:00 2001 From: kittyegg Date: Sun, 7 Jun 2026 02:44:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=83=D0=BB=D1=8F=20=D1=82=D0=B5=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=8C=20=D0=BC=D0=BE=D0=B6=D0=B5=D1=82=20=D0=B2?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D0=B4=D1=80=D1=83=D0=B3=D1=83=D1=8E=20=D0=B1=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Turret.cs | 6 ++++++ Assets/Scripts/TurretBullet.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Assets/Scripts/Turret.cs b/Assets/Scripts/Turret.cs index 16f7518..5490019 100644 --- a/Assets/Scripts/Turret.cs +++ b/Assets/Scripts/Turret.cs @@ -94,6 +94,12 @@ public class Turret : MonoBehaviour _reloadTimer += Time.deltaTime; } + private void OnTriggerEnter(Collider other) + { + if (other.TryGetComponent(out TurretBullet bullet) && bullet.From != this) + Destroy(bullet.gameObject); + } + private void SpawnBullet(Vector3 direction) { if (_reloadTimer < _reloadTime || !DetectEnemy(direction)) diff --git a/Assets/Scripts/TurretBullet.cs b/Assets/Scripts/TurretBullet.cs index 50252ac..e1d365c 100644 --- a/Assets/Scripts/TurretBullet.cs +++ b/Assets/Scripts/TurretBullet.cs @@ -8,6 +8,7 @@ public class TurretBullet : MonoBehaviour private Vector3 _spawnPos; + public Turret From { get; private set; } public float Damage => _damage; public float Distance => _distance; @@ -28,6 +29,7 @@ public class TurretBullet : MonoBehaviour var rot = turret.transform.rotation; rot.SetLookRotation(direction); var bullet = Instantiate(this, spawnPoint, rot, turret.transform); + bullet.From = turret; bullet._damage += turret.Damage; bullet._distance += turret.Distance - Vector3.Distance(spawnPoint, bullet.transform.position);