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

Add play_event_at function for one-off events #74

Closed
wants to merge 1 commit into from
Closed

Conversation

GitGhillie
Copy link
Collaborator

Fixes #72

@GitGhillie GitGhillie requested a review from Salzian March 7, 2024 13:51
@GitGhillie GitGhillie added the enhancement New feature or request label Mar 7, 2024

pub fn play_event_at(&self, transform: Transform, path_or_id: &str) {
let event_description = self.0.get_event(path_or_id).unwrap();
let event_instance = event_description.create_instance().unwrap();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new instance ad-hoc every time this function is called smells like a performance issue to me.

When an event instance is created, any required non-streaming sample data is loaded asynchronously.

This would incur loading and unloading the sample data at the mercy of FMOD. I can imagine this can possibly cause delays when trying to play the sound immediately, as a one-shot usually requires.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah you're right, the API guide even calls this out.

In practice it doesn't seem to be a problem: https://discord.com/channels/691052431525675048/1215038273445961758/1215317674595192852

But I realize now that users can already create their own play_event_at function with the way things are, so I think we can leave this PR for now until we fix #20

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave things as they are for now to ensure samples are loaded when needed. We could add a utility function that combines playing a sound and moving the entity to the desired position.

@GitGhillie GitGhillie closed this Mar 11, 2024
@GitGhillie GitGhillie deleted the oneshot branch March 11, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability for one off spatial sounds
2 participants