smear out blink times so enemies don't blink in clusters
This commit is contained in:
parent
f4a0dc57c3
commit
ce56b6d829
2 changed files with 8 additions and 12 deletions
|
|
@ -14,6 +14,5 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.EnemyAbilities.BlinkAbilityDefinition
|
m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.EnemyAbilities.BlinkAbilityDefinition
|
||||||
DisplayName: Blink
|
DisplayName: Blink
|
||||||
Description: Enemies occasionally teleport a short distance ahead.
|
Description: Enemies occasionally teleport a short distance ahead.
|
||||||
IntervalSeconds: 4
|
IntervalSeconds: 8
|
||||||
BlinkDistanceMeters: 4
|
BlinkDistanceMeters: 4
|
||||||
StartJitterSeconds: 1.5
|
|
||||||
|
|
|
||||||
|
|
@ -25,25 +25,22 @@ namespace TD.Gameplay.EnemyAbilities
|
||||||
[Header("Blink")]
|
[Header("Blink")]
|
||||||
[Tooltip("Seconds between blinks.")]
|
[Tooltip("Seconds between blinks.")]
|
||||||
[Min(0.1f)]
|
[Min(0.1f)]
|
||||||
public float IntervalSeconds = 4f;
|
public float IntervalSeconds = 8f;
|
||||||
|
|
||||||
[Tooltip("World units to advance along the path per blink.")]
|
[Tooltip("World units to advance along the path per blink.")]
|
||||||
[Min(0.1f)]
|
[Min(0.1f)]
|
||||||
public float BlinkDistanceMeters = 4f;
|
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)
|
public override void ServerOnSpawn(EnemyAbility instance, int abilityIndex)
|
||||||
{
|
{
|
||||||
// Seed each enemy's cooldown with a different negative offset so the wave's first
|
// Seed each enemy's cooldown with a random point within the full interval, as if it
|
||||||
// blink is staggered. Done once, here, rather than on the first tick — a tick-time
|
// 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
|
// check would have to distinguish "never started" from "just blinked", and both
|
||||||
// states read as a zero timer.
|
// states read as a zero timer.
|
||||||
if (StartJitterSeconds > 0f)
|
instance.TimerFor(abilityIndex) = -Random.Range(0f, IntervalSeconds);
|
||||||
instance.TimerFor(abilityIndex) = -Random.Range(0f, StartJitterSeconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ServerTick(EnemyAbility instance, int abilityIndex, float dt)
|
public override void ServerTick(EnemyAbility instance, int abilityIndex, float dt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue