How do i play audio using a key press, I have a radio in my level that I want to activate using a key on the keyboard and I cant find any youtube tutorials out there telling me how to do it
There is a node: Play sound at location (or something like that).
Key event > play sound at location (desired sound, location of the radio). Done.
Can you provide an image of the blueprint of what I need to do, I am a visual learner so that would help a lot
Here you go.
Q is just an example obviously.
In the sound dropdown list select the sound asset you want.
In location input location of the source of sound in game world.
I got all of that done, how do I get the location of the sound, I tried dragging my Music component into the blueprint but that wouldn’t hook up to the location.
Here is what I have so far
I am a total beginner at using audio if you didn’t notice, it would be nice if epic did a class maybe on twitch, on this kind of basic audio stuff for beginners like me
Ok…
I think you should learn a bit about blueprint communication, because this might get complicated. There is a lot of videos about it on YT.
This is a lot to explain in a comment. And there are multiply ways of doing it. Do you know about “get all actors of class”, references and casting?
If you have an actor with sound component than you don’t need “play sound at location” node, you just play if from the component.
Your script is not in pawn or player controller so the key event wont trigger because only a player controller and pawn receive player input.
I don’t remember if level blueprint receives player input. If so it would be very easy. Open level blueprint with you actor placed in world and selected. Right click in the editor and you will be able to reference that actor in level blueprint. From there add key event, get component from the reference and play sound.
Can you provide an example of the easiest way to do this, or at least provide a youtube video of how its done, do you have time to make me a blueprint with this functionality or should I just scrap this whole idea
Your Radio is just a mesh or is a BP Class?
If this is a BP, and it is the BP your are showing in the pics, grab the “Get Actor Location” node and connect to the Location node.
Its still not working, it shouldn’t be this hard to push a key on the keyboard to play a sound, about ready to tear my hair out. Here is what I have so far
Ok, probably your radio BP does not receive inputs. Make this input event inside the player controller or your pawn, then call a function inside the BP radio class to execute the same logic as you show in the picture, but receiving a function call instead of an input.
Let me know if you got it right
Can you please show me how to do this in blueprints, put a screenshot up, cause what you just said makes no sense, I am a visual learner so images help a ton
The player can activate the sound anywhere and at any time?
Can you post a screenshot showing me how to do this and I dont want to activate it at anytime, I just want to turn on the radio when i am right by it like in real life.
I can’t do this right now, sorry. Gotta go, but the guy in this video is trying to make something like this, but with the trigger box. Just change the Event OnActorBeginOverlap for your input key and it might work, if a quick result is what you are in need.
In addition to this, you must use a branch to check if the actor is inside a range, which can be represented by a Sphere Collision, to make it works when you are next to it.
I can help you later if you are still stuck in it, luck!
Yea I have seen that video, but I cant turn on the music player and turn it off, so I dont think that would work
I would set up a function called Interact on your main pawn, and set up a function called ToggleRadio on the radio.
For ToggleRadio the function, when it is called, do a flip flop. For A, play sound at location (location is get actor location, self). For B, stop sound. You’ll have to add the sound as a component to the radio I think. Or spawn the sound and save it as a variable.
For the Interact function on your pawn.
Set it up so when you press F, or E or whatever you’d like it calls the new function Interact.
When interact is called, we’re going to do a line trace by channel. The start location of the line trace will be Get Player Camera Manager -> Get Actor Location.
The end will be the following math> Get Player Camera Manager -> Get Forward Vector * float(1000) = X Get Camera Manager -> Get Actor Location + X = End
Then break the Hit trace results, and for Hit Actor, cast to BP_Radio (or whatever you named your radio) and call Toggle Radio
I’ll do this up in BP to show you when I’m done supper in a few minutes if you still need help, which you might, because this is a lot at once, even though it’s quite simple once you understand it all.
Edit: I made a video tutorial for fun
So I got it working using your video but how do I get it to turn the radio off