Set sound doesn't find my audio file

Hi all,
I’m trying to create a toggle sound, one that plays when a button is held, and stops immediately when it is released. I was following a thread here, where it was told to use the set sound command to bind the sound cue to an audio component, then one can play and stop it.
I did just that and I get errors that I do not have the file to play, even if I do, I could not set the file as default to my audio component. Any ideas?
Thanks in advance.

which thread ? why don’t you use play sound 2D or spawn sound or simply play sound at location?

why don’t you use spawn sound? and simply stop that by press (save it as variable) sound is .wav right?

you are not using SET to set the audio component are you? you are sure you
using SET to to the sound (set sound node?)

can you share a pic of BP you have made so far?


just attach it on answerhub using the add image button at top (of comment/answer section)

Greetings!
Here is the rig:

By the way I just realized it was an UE forum thread, not here:
https://forums.unrealengine.com/showthread.php?2478-Play-a-sound-when-key-is-pressed-stop-when-no-longer-pressing

By the way, how to stop a sound from playing when using the play sound function? I use play sound everywhere, except here.

may i know here your sound component is?

by using spawn sound 2D you can

see my above comment as well

@Prithvi Singh with spawn sound, promoting it to a variable then stopping it works, but I get runtime errors, like “attempted to access AudioComponent_1 via property TensionSoundSpawn, but AudioComponent_1 is pending kill from function ExecuteUbergraph…” etc.
I did have an audio component on my first setup and it was editable as well :confused:
I also tried to spawn it only at the event construct, promoting to a variable then play and stop, but that didn’t work out.
And no, I was not setting the component itself, I was using the SetSound function. I have a .wav file. I have no idea, what the issue is :frowning:


where is your component? is it in an actor or player? you need to specify that as widgets , i don't think they have one audio component they are supposed to get them from other sources and tell them what to do.

It’s an audio component reference. Have it where you have it and it has the same colour. How to specify as widget? I did it exactly as you did now and it works, it just gives the same error I mentioned.

However, no matter how often I START playing it by holding the button, it does not give errors as long as I don’t let it finish. As soon as it finishes, I get the error.

like this i give it a reference that this is the component the sound should be in

I don’t really have a player character. The game uses widgets only. All other sounds work just fine, this one is malfunctioning (giving errors) only when the sound stops - ends - before I release the button.

and seems like it doesn’t matter if I have a wave or a cue as sound, it gives this error all the time I have the button pressed while the sound is finished.

Another edit: I got it working with looping sounds, it isn’t that big of a deal if I get the tension sound regardless of the part moving or just under tension.
Now, does this spawning create sound components over and over again, or it just creates one? I have this spawning the way you showed. I’m curious because of the limited memory that mobile devices have.

i don’t know about that but it does have a destroy component node but looping should just loop it not replicate /duplicate