I am beyond livid with blueprint interfaces and casting and the lack of in depth documentation

So, here’s the problem.

I’m trying to make a sound play after clicking the play button on the main menu. I’m trying to use an interface to do it, after failing miserably with trying to cast to the blueprint. I have a blueprint interface set up, and the two blueprints communicating at least how I think they should, since there is a lack of any good documentation or tutorials I can find that are more in depth than just skimming over the topic.

I’ve been working at this for 5 hours and my hair is about to fall out.

I never see the console message fire. What do I have hooked up wrong? Is it my reference variable? Is it the interface call itself? What am I doing wrong? I feel like every time I make progress with blueprints I immediately take two steps back.

Thank you in advance for the help, and also for reading my half venting rant/half question.

Possibly an issue with the reference. Do you have any screens showing how you’re getting the reference to Beepsbp in the hud?

Also, as a side note, do you need this sound to be in a different blueprint? Usually for UI sounds i would store the sound as a variable in the Hud itself, and just use the “Play Sound 2d” node at the OnClicked event. Plug the sound variable into that node and that should work fine.

What I would like is the sound to play when the main menu disappears. It’s a background noise, ambient with no attenuation. More like BG music, but a looping sound effect. I then want to be able to call this sound cue again later from a matinee event or from the creation of a different user widget to fade the volume down to half.

As for the reference, it is a variable I created in the widget Main Menu BP (sorry, I named the screenshots, apparently it doesn’t keep those file names intact on upload.) I then assigned the variable type by clicking on it, typing “beepsbp”, and getting a reference to it as an object type.

Here are full window screenshots of MainMenuBP, INT Sound, and Beepsbp.

If i’m understanding you right, it sounds like youve created a variable and given it the type ‘object’, but havent actually assigned it to your sound-playing Blueprint. Currently the variable is just an empty object until you tell it what specific object it’s supposed to be referring to.

That third screenshot you sent, of your sound playing blueprint, is that an object or actor placed in the world? If it is, there are a couple of ways you could get a reference to it.

In the HUD, on begin play/construct, you could use the node ‘get all actors of class’, select beebsbp as the class, and that should give you an array of all actors in the level that use that class (this will work best if you are sure that you only have one actor of that kind in the world). You can then get the first element of the array (with only 1 actor in the world, that will be the one you want), and then assign that to your beepsbp variable in the hud.

From there you should be able to call that playsound function I believe.

beepsbp is an ambient sound blueprint, int sound is an interface and mainmenubp is a user widget bp.

the beepsbp variable is in the mainmenubp blueprint and the way i assigned it is included in the following screenshot.

You’re advice worked! It calls the interface. I thought choosing the variable type and selecting the bp would assign the variable. I deleted the ref and just did what is pictured below in the screenshot. Is there an easier way to implement interfaces? It seems like it’s basically casting but with an extra step. Aren’t interfaces supposed to be a list of functions with custom inputs and outputs that can be called as events from other blueprints? It seems really inefficient.

Are there any good tutorials on the nuances of blueprint interfaces, comms and casting?

The thing with interfaces is that lots of different kinds of actors/classes can use them. You could theoretically have a completely different actor, nothing to do with sound, that implements the ‘sound interface’, and you could call ‘play sound’ on it. In that actor’s blueprint you could then define play sound to do something else if you wanted. Not that you’d ever want to do that in that example, but it’s useful for other things. For example I use a ‘take damage’ interface, and i put it on anything that i want to use a ‘take damage’ function for. But I have different actors that react differently to that function (characters lose health, environment object like boxes etc might break open, stuff like that).

You shouldn’t always have to use casting to use an interface though, the issue you were having was just that your variable wasn’t actually referring to anything (you could have had more than 1 beebsbp in the world and it wouldnt know which one you were trying to call the function on).

As a side note, you only need to get this reference once, and the get all actors of class can be expensive performance-wise, so i wouldn’t put the ‘get all actors of class’ node in the on play button clicked event. I would put that in the ‘event construct’ node of the HUD, store that in your variable, and then you can just use that variable from then on, as many times as you need.

Glad that works for you though!

One last question, if you could. I just want to play certain sounds and have control over their loudness and when they fade out depending on events that all happen within one UMG blueprint. What am I doing wrong?

You may want to change youre variable name and re upload youre screenshots pretty sure swearing on forums is against the terms of use

I’ve already deleted the screenshots off my desktop and the blueprints have changed drastically since they were taken, so I won’t be reuploading them. I’m sorry I offended you, I didn’t notice the variable name that I used. If they have no merit in helping others who went through the same problems, then i have no issue with the mods deleting them.

I wasnt offended mate it actually made me laugh was just warnimg you because the mods can be quite strict on here .

No problem. I didn’t mean to sound snippy or anything. I’m just drained and frustrated after the hours and hours of trying to get one or two things working.

Your last question might be a little bit beyond my current knowledge unfortunately Kenjamin. I haven’t played around too much with fading sound for my projects just yet. As far as i can see that particular snipping looks like it should work but I can’t be sure.

Where are you calling that bit of code from? Could there be a problem with that fade functionality getting called earlier on?

Swearing is, but avoiding word filter is like 2 infraction points. However i do not think anybody got it, we usually warn people.
I know how frustrating unreal can be, for eg i was screaming whole weekend at my monitor.

Back on topic, i think i got interfaces mastered by now. So ask if you have problems with it.

Basically, the overall goal is as such:

I have a UMG as a computer interface. I can play sounds and such by using a Play 2D node, but I would like to be able to stop those sounds or fade them out at specific times depending on events or buttons clicked inside the UMG widget. What approach should I use.

Based on my limited knowledge, I figured I would use a blueprint, add all the audio files as components, and then use custom events in the event graph of that BP to tell a sound to play or stop or fade. All the tutorials I can find show how to set up a variable to be able to use as a reference to a blueprint, the only problem is, every tutorial shows the same thing: blueprints in a level where you can expose the variable for the blueprint you want to reference, and then click on the blueprint in the level to assign that variable. I have no idea how to set a blueprint as a reference for a variable if its not in the level.

I wish there was an easier way like calling a node on an event to play a sound and then having that node have a return to set as a variable to call later to fade it out.