From 7f317bd33274a0cd8d496e4100ca49c80af40985 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 22:15:53 +0200 Subject: [PATCH] Freeze a guided round that waits on its verdict and place a positionless hit at its target After its fade a round kept integrating Velocity through the BindingLifetime wait, then a Hit (which carries no burst point) played HitEffect at the drifted position. The wait now holds still; a hit without a point plays the effect at the round's target position, and is skipped when the round never knew one. OnEnable resets BindingLifetime so a pooled split child, which is never bound, does not inherit the last round's. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Gameplay/Weapons/GuidedProjectile.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Gameplay/Weapons/GuidedProjectile.cs b/Assets/Scripts/Gameplay/Weapons/GuidedProjectile.cs index 4eb75f1ad..26a6db650 100644 --- a/Assets/Scripts/Gameplay/Weapons/GuidedProjectile.cs +++ b/Assets/Scripts/Gameplay/Weapons/GuidedProjectile.cs @@ -98,11 +98,14 @@ public class GuidedProjectile : MonoBehaviour return; } StopAllCoroutines(); + // A hit carries no burst point: the effect plays where the round was homing (a round that faded out has stopped + // short of it), and is skipped when the round never knew where its target was. + Vector3? effectAt = point ?? (TargetPosition != null ? TargetPosition() : Target ? Target.position : (Vector3?) null); if (point.HasValue) transform.position = point.Value; - if (HitEffect != null) + if (HitEffect != null && effectAt.HasValue) { var ht = HitEffect.Instantiate(); - ht.position = transform.position; + ht.position = effectAt.Value; } StartCoroutine(Kill()); } @@ -111,6 +114,7 @@ public class GuidedProjectile : MonoBehaviour { _active = _alive = true; _spawnTime = Time.time; + BindingLifetime = 0f; // a pooled round starts unbound; the manager binds it after enabling _phase = Random.value * 100; _prevDist = Single.MaxValue; Particles.startColor = Color.white; @@ -222,6 +226,8 @@ public class GuidedProjectile : MonoBehaviour yield return null; } + // The wait holds still: a round waiting on the verdict must not drift off its last position. + Velocity = Vector3.zero; // Faded, but the simulation's verdict has not necessarily arrived: wait for it until the shot's flight is over. while (Time.time - _spawnTime < BindingLifetime) yield return null; StartCoroutine(Kill());