Class DecayingJitterMotion
Reproduces, as a plain enumerable, the decaying-jitter shake math shared verbatim by
ScreenShakeChannel and UiScreenShakeChannel: a direction re-rolled every
1/frequency seconds, and a magnitude that either sustains at full amplitude (persistent) or
decays linearly to zero over the duration. Extracted so the decay math is assertable without a
coroutine/Unity frame loop — see DecayingJitterMotionTests.
Inherited Members
Namespace: Serenity.Feedback.Infrastructure.Channels
Assembly: Serenity.UnityFeedback.Infrastructure.dll
Syntax
public static class DecayingJitterMotion
Methods
Play(float, float, float, bool, Func<float>, Func<Vector3>)
Lazily produces one JitterSample per shake "frame". A caller drives it one sample
at a time — typically foreach (JitterSample sample in Play(...)) { Apply(sample); yield return null; }
so each sample corresponds to one real frame — applying the sample, then letting the next
enumeration pull advance elapsed time by calling deltaTimeProvider again.
Declaration
public static IEnumerable<JitterSample> Play(float durationSeconds, float amplitude, float frequency, bool persistent, Func<float> deltaTimeProvider = null, Func<Vector3> directionProvider = null)
Parameters
| Type | Name | Description |
|---|---|---|
| float | durationSeconds | Authored effect duration; floored so it can never reach/cross zero. |
| float | amplitude | Peak jitter magnitude (before decay). |
| float | frequency | Direction re-roll rate in Hz; zero/negative falls back to a default period. |
| bool | persistent | True to sustain at full amplitude indefinitely instead of decaying to zero over the duration. |
| Func<float> | deltaTimeProvider | Per-sample elapsed-time source, called once per sample; defaults to UnityEngine.Time.unscaledDeltaTime. |
| Func<Vector3> | directionProvider | Direction source, called once up front and again on every re-roll; defaults to a random unit-sphere direction. |
Returns
| Type | Description |
|---|---|
| IEnumerable<JitterSample> |