NiklasEi / bevy_kira_audio

A Bevy plugin to use Kira for game audio
Apache License 2.0
317 stars 55 forks source link

Does SpacialAudio as a singleton resource make sense? #121

Open mgi388 opened 2 months ago

mgi388 commented 2 months ago

There's a resource SpacialAudio that users must add to their app and it contains the distance to use for deciding when audio should be on/off. See https://github.com/NiklasEi/bevy_kira_audio/blob/763cd923ddcde328ba0b9f8d56f17783c82e3478/examples/spacial.rs#L9

But does it make sense that this value should be used for all emitters? Imagine an RTS. If you have a river, it might make sense for max_distance to be high so that you can hear the river from quite a distance in your map (e.g. when you zoom right out it's nice to hear it).

But for other emitters, like an animal walking around on the ground, max_distance being really large (and the same as the river) means that the animal would be heard even when zoomed right out.

Would it make more sense to have this value provided by emitters? The resource could be kept as a global fallback, and let emitters override it.

What do you think?

NiklasEi commented 2 months ago

I think you are right and this would make more sense on emitters. This is one of those points where one can see that I never actually used spatial audio myself apart from writing spatial example in this repo.

When this is changed, it should be kept in mind that the SpacialAudio resource is also used as an on/off switch for spacial systems.