Tension
All the director watches is one number: tension (0–1). TensionModel builds it in three steps:
normalize the two signals to 0–1 → combine → smooth.
The three steps
- Normalize — bring player threat and nearby activity each into the 0–1 range.
- Combine — if either is high the whole thing rises; if both are high it's near the max (never over 1).
The formula is
1-(1-a)(1-b). - Smooth — rise fast, fall slow. Danger should register immediately; relief should arrive gradually.
Two ways to combine
- Default:
1-(1-a)(1-b).- Sharper: just the larger of the two,
Mathf.Max(a, b).The key is "rise fast, fall slow." That's what makes the build-up → peak → relax flow feel natural.
Public surface
Damage is immediate, threat is gradual
Inside Tick, closer threats accumulate more, and stress decays gradually over time.
Injecting signals for tests
The two sample methods are virtual, so a test can inject signals directly without a physics scene
(swapped in place of an interface).
The default SampleThreat counts nearby enemies via Physics.OverlapSphere; SampleAround weights
world.ActiveEvents so that closer, bigger events count more.
Tuning — TensionConfig
Strengths, radii, weights, speeds and thresholds are all data. Tune the ranges in your game.