Audio component in Blueprint plays immediately on starting

Completed the Blueprints Quick Start Guide and now attempting to add an audio component to play a sound when I hit a trigger (Blueprints Quick Start Guide | Unreal Engine Documentation

It appears to work, but the blueprint also fires the audio component as soon as the blueprint runs, eg, as soon as I hit play in the blueprint editor, or when I hit play to test the level.

I’m obviously doing something wrong, but I can’t find any information about how I should use the component correctly. Any advice on what I’ve done wrong?

Attached pic of how I’ve set it up.

Thanks

You need to tell it to stop on play. By default all actor components have ‘Auto Activate’ set to true. You can either uncheck that box and manually activate it, then play or you can call the stop function on your BPs play event.

3 Likes

That’s excellent, thank you. I did think it was going to be something like this. I can see the Auto Activate check-box now. I had checked through the details panel a couple of times before and somehow missed it.

I don’t suppose you have a link to some documentation about blueprints that mentions this or advice with how to find it? This is something I should have been able to see for myself, but the audio component documentation I could find didn’t mention it.

Thanks for the quick answer.

I apologize in advance for necrobumping, and I apologize further for what is going to be a very long and snarky little rant, but I was having this exact issue and spent about half the morning tearing up my blueprints, trying to figure out why my object instances were all playing their sound cues at once when the game started, EVEN WHEN I REMOVED ALL REFERENCES TO THE SOUND CLIP FROM MY BLUEPRINT. After scouring the documentation for Audio components and finding absolutely zilch, and then googling the issue eight ways from Sunday and coming up with nada, I finally found this thread. However, I notice the answer provided still doesn’t quite explain the solution to the OP’s problem and I still had to fiddle around with it a bit.

So, for the benefit of anyone else who runs into this issue, here is what you have to do:

Open your blueprint and select your Audio component. In the Details panel, AAAAAAAAALL the flippin’ way down at the very bottom, is a tiny little section called “Activation” that has only one thing in it: a single flag called “Auto Activate” that you probably didn’t even know was there and would never have thought to look for. Uncheck this stupid, stupid little box.

You will note that now, when you start the game, the annoying audio at the beginning no longer plays. However, you will also note that the audio on your blueprint no longer works when you actually want it to, either. Here is how you solve THIS part:

In your actual blueprint script, drag out a Get reference to your Audio component. Drag a pin out from this, and type in “Activation.” IMPORTANT: you have to do this somewhere either in the Event Graph or inside a function. If you try to do this in the Construction Script, the only thing that will be available is a function called “Set Auto Activate” that does nothing except set the Auto Activate flag.

Even knowing this much, you can still end up with some weird results depending on where you call the Activate function. The only practical solution I’ve found is to call Activate just before you call Play, at the moment in your script where you actually need the sound to play. It’s something you only have to do once (I think), but as far as I can tell it doesn’t hurt anything to call the function again once the component is activated. However, you DO NOT want to call it from Event Begin Play, as this will just make the clip play at the beginning of the game again.

So, in short:
uncheck Auto Activate in details > go to Event Graph > get Audio Component reference > call Activate > call Play

And there you have it, that’s how it’s fixed. God only knows how many dev suicides I just prevented by explaining this convoluted workaround for an unbelievably ridiculous problem that (for once) was not caused by sloppy scripting on my part.

Seriously though, Epic, you guys need to fix this. By and large I love your engine, I love how easy to use and intuitive the blueprints system is, and I have had a lot of fun playing with it. However, this is by a wide margin the most idiotic problem I have ever had to waste half a morning debugging. There is absolutely no plausible reason why audio clips attached to objects should automatically play themselves when the game is started unless the developer has the presence of mind to uncheck some obscure little box that’s buried at the absolute bottom of the details panel. It makes even less sense to then force the developer to call a separate function just to enable the component to do what it ought to be able to do by default in the first place.

I have never played a video game in which every single sound clip in a level simultaneously plays in a horrendous cacophony at the moment the level is first loaded. I can’t imagine why any developer would want to intentionally make this happen. Thus, I can’t understand why this would be a built-in default that can only be circumvented using a not-even-remotely-obvious-or-intuitive workaround that is not even mentioned anywhere in the documentation that I can find.

Is there any reason the Auto Activate flag needs to be enabled on Audio components by default? Is there any reason why the Audio component’s various functions can’t have a call to the Activate function built in, so that you have options other than A) the sound in your game doesn’t work unless you explicitly ask it to start working, or B) your game opens with the sound of every single door in your level playing its opening and closing sound at once? I don’t know how all of this works under the hood, but it feels like there ought to be some kind of relatively simple solution that could be duct-taped together for the next version. Just…food for thought.

Anyway, once again: sorry for writing a book, sorry for necrobumping, and sorry for ranting, but I maintain that everything in this post is 100% justified. Hopefully it helps save a few people from suffering the same frustration I have had to endure. Thank you and goodnight.

6 Likes

Necro reply to your necro bump since I just ran into this in the tutorial as well

I think that a Stop after event BeginPlay would make more sense, like the user above you says:

image

Manual activation seems like a pain and error-prone in comparison

My guess is that the engine does this because we’ll typically be creating audio components dynamically, and in those cases you do want it to play instantly.
Would love to be corrected btw