Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RobWalt
Copy link

@RobWalt RobWalt commented Jul 26, 2024

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.

Copy link
Owner

@NiklasEi NiklasEi left a 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 {
Copy link
Owner

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(
Copy link
Owner

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 {
Copy link
Owner

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants