public sealed class AudioScattererThrows a sound around at intervals, which is most of what an ambience is.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The cheapest thing that makes a place feel inhabited. A looping ambience bed says "forest"; birds at irregular intervals from irregular directions say "you are in a forest". The second is a timer, two random numbers and a call to Play, and it is worth more than almost anything else of the same size.
It is a caller of AudioEvent and not a part of one. Everything that makes the individual spawn good — which of the five bird calls, its pitch variation, how many may overlap, how far each carries — is the event's job and already done. What is left is when and where, which is this and is about forty lines.
Nothing is allocated by a tick, and a tick that does not spawn is a subtraction and a comparison. A level with fifty scatterers costs fifty of those a frame.
Fields and properties (5)
public Vector3 OriginWhere it scatters around, when it is not following the listener.
public AudioScattererSettings SettingsHow often, how far and how wide.
public bool IsRunningWhether it is throwing anything.
public int SpawnCountHow many it has thrown since it started.
public float NextSpawnSecondsHow long until the next one, in seconds.
Methods (7)
public AudioScatterer(AudioEngine engine, AudioEvent sound, AudioScattererSettings settings)A scatterer that throws an event about.
public void Start()Starts it, with the first spawn a random interval away.
public void Stop()Stops it. Anything already playing is left to finish.
public void StopAll()Stops it and stops everything it started.
public VoiceHandle Update(float deltaSeconds)Ticks the timer and spawns if it has run out.
public VoiceHandle SpawnNow()Throws one now, wherever the next one would have gone.
public Vector3 Scatter()Picks a point to throw the next one at.
Used by (1)
- ScattererTestsVixen.Audio.Tests