smear out blink times so enemies don't blink in clusters

This commit is contained in:
Ian Woods 2026-08-04 21:47:08 -07:00
parent f4a0dc57c3
commit ce56b6d829
2 changed files with 8 additions and 12 deletions

View file

@ -25,25 +25,22 @@ namespace TD.Gameplay.EnemyAbilities
[Header("Blink")]
[Tooltip("Seconds between blinks.")]
[Min(0.1f)]
public float IntervalSeconds = 4f;
public float IntervalSeconds = 8f;
[Tooltip("World units to advance along the path per blink.")]
[Min(0.1f)]
public float BlinkDistanceMeters = 4f;
[Tooltip("Random spread (seconds) added to each enemy's first blink so a wave doesn't " +
"blink in one synchronized block. Applied once, at spawn.")]
[Min(0f)]
public float StartJitterSeconds = 1.5f;
public override void ServerOnSpawn(EnemyAbility instance, int abilityIndex)
{
// Seed each enemy's cooldown with a different negative offset so the wave's first
// blink is staggered. Done once, here, rather than on the first tick — a tick-time
// Seed each enemy's cooldown with a random point within the full interval, as if it
// spawned already partway through a cooldown. A small jitter window near zero would
// still let a burst of enemies spawned together sync up and blink as a visible cluster
// every cycle; spreading across the whole interval avoids that regardless of how
// IntervalSeconds is tuned. Done once, here, rather than on the first tick — a tick-time
// check would have to distinguish "never started" from "just blinked", and both
// states read as a zero timer.
if (StartJitterSeconds > 0f)
instance.TimerFor(abilityIndex) = -Random.Range(0f, StartJitterSeconds);
instance.TimerFor(abilityIndex) = -Random.Range(0f, IntervalSeconds);
}
public override void ServerTick(EnemyAbility instance, int abilityIndex, float dt)