Forum rules - please read before posting.

Inventory Items Overlapping sounds

Context: In my items inventory, I set each item to play a sound each time I click an item. The problem is I have a lot of items in my inventory. This is how I set the sound.
In the AC GAME Editor > Inventory > "Item 1" > Item 1 settings > Standard Interactions > Item 1_Use > Action Type: Sound, Play one-shot > Clip to play: item 1 sound.mp3

I have given each item to play an mp3 file to activate when I click.
So the problem is whenever I click multiple items, the sounds overlap.
How do I stop playing the item 1 audio when I click the item 2 audio?

Comments

  • Welcome to the community, @skidrenz.

    "One-shot" audio is played independently of other sounds - if you want each sound to interrupt the previous, you'll need to use a dedicated AudioSource that will stop the previous when a new is played.

    To do this, add a new Sound object in the scene, make it a prefab, and remove from the scene. Attach to it AC's "Constant ID" component, and check Retain in prefab?.

    Then, replace your Sound: Play one-shot Actions with Sound: Play, have them reference the prefab and assign the same audio clip as before.

    You then just need to make sure this Sound prefab is present in each scene. You can do this either by manually placing it inside each scene Hierarchy, or by spawning it with the Object: Add or remove Action inside the Scene/ Change/ After event, which can be generated from the Events Editor in the top toolbar.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.