#[non_exhaustive]pub struct AudioEmitter {
pub sound: Handle<Sound>,
pub params: PlayParams,
}Expand description
A sound that plays at its entity, and follows it as it moves: the system
nadir::sound starts it once its sound has loaded, while the entity has
a Transform and is within
AudioConfig::max_dist of the
listener (AudioListener), 800 pixels, where it can be heard. It
stops, fading out over 100 ms, when the entity is despawned or loses
the emitter or its Transform, or is more than 64 pixels past that
distance; back within it, it starts again. A sound that does not loop
plays once each time it starts.
Changed, it follows: a new sound, bus, looped, priority or
max_instances stops the voice and starts the new one, and a new
volume or pitch reaches the voice as it plays. Its pan is not
used: where it is pans it.
A voice taken for another when the voices run short stays silent until
the emitter starts again. PlayParams::priority protects it only
from plays of a lower priority: AudioEmitter::looped’s 192 from
sounds played with the default, 128. A sound that failed to load, or
that the asset server does not hold, is warned of once, with the entity
and its path, and not tried again until the emitter changes.
It is not reflected: a game gives it in code, not in prefabs or levels.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sound: Handle<Sound>The sound it plays.
params: PlayParamsHow it plays it.
Implementations§
Source§impl AudioEmitter
impl AudioEmitter
Sourcepub const fn new(sound: Handle<Sound>, params: PlayParams) -> Self
pub const fn new(sound: Handle<Sound>, params: PlayParams) -> Self
An emitter of sound, played as params say.
Sourcepub fn looped(sound: Handle<Sound>) -> Self
pub fn looped(sound: Handle<Sound>) -> Self
An emitter of sound looped on Bus::Ambience, for a sound of
the place, such as water or a fire: at priority 192, and with no
limit to the voices of the sound, so that the sound’s limit does not
make its emitters take one another’s voices; when all the mixer’s
voices play, a play of the same priority or higher still takes the
oldest of them (Audio::play_sound).
Otherwise as PlayParams::default plays.