Skip to content

AudioSink is not updated when audio source component is replaced #11862

@rambip

Description

@rambip

Bevy version

bevy = { version = "0.12.1"}

What you did

Here is the code I have problems with:

https://gist.github.com/rambip/43a977c833edef252ae7e3d17203287a

To resume, I:

  • create a custom audio source like in the "decodable" official example
  • add it as a component to start playing it
  • change the component with another audio source
  • set a control on the space bar to play and pause the sink associated with the entity

What went wrong

I expected this code to play and pause the lowest-pitch sample.
But it plays nothing.

I tried a few other experiments (like rechanging the audio-source to the original one, and then it worked)

I found a way to do what I intended: forcing the sink to be destroyed when I change the source.

Discussion

I don't think it is the expected behaviour, or at least I think it is very confusing. My take is that the Sink should be removed when you insert an audio-source on an entity that already has one.

The user should know how the sinks are created and modified when the sources are spawned. Otherwise you quickly run into strange behaviours that are hard to debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AudioSounds playback and modificationC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions