You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use dynamic channels to play different sounds like background, walking sounds etc. I use an event to play the sound. Later in the system I am checking if given channel is playing sound and then replace it, if it is.
fn start(
mut evs: EventReader<PlaySound>,
ass: Res<AssetServer>,
mut audio: ResMut<DynamicAudioChannels>,
){
for ev in evs.read(){
let mut audio_to_play: Option<PlayAudioCommand> = None;
let Some(channel) = audio.get_channel(&ev.channel.to_str()) else {continue;};
info!("{:?}", channel.states);
if channel.is_playing_sound() {
match ev.soundsos {
SoundSOS::Abandon => {/* Do nothing, there is already a sound in a channel */}
SoundSOS::Replace => {
channel.stop();
audio_to_play = Some(channel.play(ass.load(format!("sounds/{}.ogg", ev.sound_name))));
}
}
} else {
info!("NOT PLAYING SOUND");
audio_to_play = Some(channel.play(ass.load(format!("sounds/{}.ogg", ev.sound_name))));
}
....
Turns out the channel.is_playing_sound() returns always false, even though sound is playing (more and more of it :D) I checked the channel.states but they are always empty in this case. I tried to dig deeper but I saw "dyn" and backed off
Version: Bevy 0.15/0.21
I wanted to use dynamic channels to play different sounds like background, walking sounds etc. I use an event to play the sound. Later in the system I am checking if given channel is playing sound and then replace it, if it is.
Turns out the channel.is_playing_sound() returns always false, even though sound is playing (more and more of it :D) I checked the channel.states but they are always empty in this case. I tried to dig deeper but I saw "dyn" and backed off
The text was updated successfully, but these errors were encountered: