-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per Entity SpatialRadius
for controlling spatial audio ranges
#128
base: main
Are you sure you want to change the base?
Conversation
imo there's no good reason to place the logic on a method of the `GlobalSpatialRadius` anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry for the long silence and thank you for tackling this.
pub struct SpatialAudio { | ||
/// The volume will change from `1` at distance `0` to `0` at distance `max_distance` | ||
pub max_distance: f32, | ||
pub struct GlobalSpatialRadius { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resource would make more sense as a field on SpatialAudioPlugin
. E.g. default_spatial_audio_radius
.
}); | ||
} | ||
|
||
fn spatial_audio_enabled( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the system won't run without the resource, even if all emitters have their own SpacialRadius
components.
I think it would be more idiomatic to just let users add the SpatialAudioPlugin
.
/// If neither this component or the [`GlobalSpatialRadius`] resource exists in the ECS, spatial | ||
/// audio is not applied. | ||
#[derive(Component)] | ||
pub struct SpatialRadius { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe SpatialRadius
could be a required component of AudioEmitter
? If so, the default value could not be changed...
It was one of the first things that naturally seemed to be missing. This basically tackles #121.
I updated the example, so now the cooking pot is only hearable if you're really closeby while you can still listen to the radio from a greater distance.
There were a few other small changes I made when working on this. I just couldn't help but make the code here and there more idiomic.