Trying to implement the idea of the thread title using Blueprint, which actually seems a little un-intuitive to me at the moment.
The idea is to set up a Blueprint where you can specify both the sound (that loops) and the input key, in the construction script area. Then in the event graph I am trying to set things up so that when you press the key, the sound is played continuously until you let go, when it will stop.
This does not seem straightforward with what is available. Any tips on how to complete this seemingly simple task? The audio capabilities donât seem to have a way to âstopâ a sound that is playing.
Full disclosure, Iâm definitely not an expert on audio through blueprints, but I believe one way you could do this would be to add an audio component to the actor blueprint you want to do this in and then use the âSetSound,â âPlay,â and âStopâ blueprint nodes available off of the component.
For a quick experiment, I just set the sound on the component in BeginPlay (but you could do this in the properties window of the component if itâs just going to be one sound that doesnât change), and then used Play and Stop when the right-mouse button is pressed and released, respectively.
Hey Billy, thanks for the incredibly fast response. This seems to make complete sense and will give it a shot. Funny that I would greatly prefer code in this case, but we are starting with Blueprints to make it more accessible to everyone. But I was dying to do a simple audio.play()/stop()!
This also helps with some insight on how Blueprints work. Thanks again!
Edit: Didnât realize how many functions using âcontext sensitiveâ was removing from the view. Play and stop are clearly right there.
No problem at all! Let me know how it goes. Hopefully Play and Stop should show up in the context sensitive option too (as long as youâre pulling off of an audio component), but I think they end up being in an awkward spot in this case, because you have to expand âCall Functionâ -> âAudioâ -> âComponents.â I totally initially missed the âComponentsâ piece being expandable when I went to get that screenshot for my last post because there just happen to be two audio related functions that arenât categorized that show up in the list as well. Will ask around if we can make that a little clearer.
Yep, this is correct. Also, if you want to have more gentle transitions, you can use the Fade In function to play the sound with a defined linear fade-in time, and the Fade Out function, which will execute a linear fade-out of the audio over a specified time and then stop.
Best-
Zak
What IF i need to :
Keypress active - play startsound - then play looped sound until i press the deactivate key then play endsoundâŚ
What im trying to accomplish is to add a âturn on tap waterâ with emitters when pressing âenterâ the water will pour and as long as i want and later when i press âenterâ again the water would stop.
I tried different ways but i being new at this my logic is probably wrong when put down in blueprintâŚ:-/
EDIT: Iâve found out that my W event isnt even firing, why is that?
Hey there,
At the moment I am trying the same thing as the started of this thread.
I am currently running into a problem with footstep sounds. Our game has no character and is in first person.
I want a soundcue to play whenever W,A,S or D is pressed and I want to stop it when W,A,S or D is released.
I created a blueprint using the soundcue and created the following blueprint:
Soundcue BP:
Add the sound cue as an audio component on the character itself. Because you arenât using animation, prototype something along these lines.
Event Tick -> Branch. For the Bool do an AND operation (isMovingOnGround AND Acceleration.Length > 0), for the True output put your Play, for the False put your Stop.
This is not a final solution, if this functions the way I think it will the timing will be way off because it will fire every Tick as long as you are on the ground and inputting WASD.
If your initial idea ended up working the same thing would occur, as the W key would be sending inputs every tick. You will need some way to delay firing the sound every tick
At the moment I am trying the same thing as the started of this thread.
I am currently running into a problem with footstep sounds. Our game has no character and is in first person.
I want a soundcue to play whenever W,A,S or D is pressed and I want to stop it when W,A,S or D is released.
I created a blueprint using the soundcue and created the following blueprint:
Soundcue BP:
Hello I want do the same and how can I add W event in Evengraph with Pressed and Released executive