I have a widget with a checkbox to manipulate the music volume between 1 and 0 (Activate and deactivate) It works well when deactivating the box, but when re-activating the box the volume it still does not sound, I got it to work if instead of using the volume 0 used the volume .01 but this is not the result I expect, my question is, why when multiplying the volume to 0 the audio can not be multiplied by 1?
Odd. I just tried this and it works fine on my end (setting the volume multiplier on a looping sound cue to 0).
I would guess that your boolean isn’t getting set, but you said you tried it at 0.1 and it worked. To confirm, the false and true print statements are seen?
EDIT: To be clear, I then set the multiplier to 1 again and it played as expected.
I wonder if this is an issue with multiplying the volume by 0 (so now the volume is 0), then later multiplying it by 1 (which would still be 0). Even though that’s not what happened in my delayed set up, it could be a problem to do with ending the execution chain then refiring it. The new volume is 0, so multiplying it by 1 gives you nothing.
Either way, try using the “adjust volume” node. That shouldn’t cause any multiplication issues (if indeed that is the issue).
Can you confirm that the sound is playing when you re-activate the box? If you use stat Soundwaves it will show you which waves are playing. Trying a process of elimination here - starting with confirming if the sound file is actually playing.
At the beginning mark a total of 1 and when I deactivate the music box it shows 0, then try to mark it again but the total sound waves still show 0 (And the music still does not sound).
Okay, so the sound isn’t playing at all, which maybe means it’s getting destroyed (even though auto destroy is unchecked)? Perhaps “create sound” will destroy the sound if it’s set to 0 volume? My guess is if you put it in an audio component on whatever actor seems appropriate, then point it to your sound cue, you should be able to change the volume without issue.
As the sound isn’t playing I can’t really see what else would be the issue. It must be getting destroyed. You could try printing the value of your music variable after your true statement and see if it changes after re-activating
I don’t know how to use Sound Cue, and i don’t have other actor on the level, just the light and Pawn (To put the sound cue). This is the result of print the value of the Music variable:
You can put the audio component on any actor that’s in the level - ideally the same actor that has the logic shown above so you don’t have to communicate between blueprints.
Using a sound cue and audio component is very easy. In the blueprint, add an audio component. Then point it to your sound cue (if it’s a wave file and not yet a sound cue, right click on the wave and “create cue”). Now if you drag the audio component reference into your blueprint graph, you can play/stop/adjust volume etc on that audio component. It’s not that different to what you’re doing, but you are currently spawning the sound and I’m less familiar with that method. Adding an audio component or audio actor in the level would be a more standard approach anyway. It’s much easier to keep track of what is playing and how if you know it’s always being routed through an audio component.
I understand that this may be a way to achieve what I want, but it is not really what I am looking for, the event creates sound 2D is already in my character, I prefer to solve this error rather than avoid it, but with the sound cue I can have 3 types of sounds? (Ambient, sfx and music?)
Yes, A sound cue provides you with an editor to perform more functions on a sound wave (such as delays, groupings, blueprint parameters etc). Many of those features are also available on the sound wave, it’s just less flexible. There’s really no difference on the users end, other than that they can do more with the sound cue, and there’s a lot of BP nodes tailored for sound cues.
But you can of course stick with the create sound method if that’s what works for you.
Yes. Then in blueprint, you manipulate the audio component to do whatever you need - change the cue, set the volume, change the soundclass or audio mix etc.
You can have multiple audio components on the actor as well - so you could have one for music, one for ambience, and one for SFX. You then mix between them however you like. I think by default they all auto activate so you’ll likely hear every audio component when you start playing. You can deactivate them in blueprint, or just set the volumes to 0.
For example in my weather controller actor, I have 9 audio components, each dedicated to a particular type of sound cue (wind, rain, snow, loops, one shots etc). It could be done with less, but it’s a nice clean way to know what is playing where, and how. I then use timelines to lerp between the audio components as needed.