Stop Overlapping

Hello,

I’m having a small technical issue with a few game-play actions.

I have an object that has a blueprint connected to it. The blueprint then, is interact-able using the Left Trigger button, upon input a dialogue plays until end with subtitles playing along with the audio.

However when I want to interact with another object (that has a similar blueprint connected to it), the audios overlap and so do the subtitles (which are basic UMG’s that are removed from the view-port when necessary)

I don’t want them to overlap, rather have one pause or stop completely when interacting with another.

Can someone please let me know how I’d do this? I’m unsure as to how I’d do it.

Thank You.

You’ve got the audio to play and the subtitles to show which is half the battle :slight_smile:

Am I correct in assuming that the spawning ( or playing ) happens in side the BP?

Somehow, you need to centralise or pass information around about which BP is currently playing, if any. Then, when a new BP wants to play it can tell the others to stop.

Two ways to do this:

  1. You can have a central BP which is the thing that plays audio. When one of your BPs wants audio to happen, it has to tell the central BP which audio to play. The central BP knows whether or not audio is currently playing and can stop it before playing the new requested file.

  2. All BPs have a ‘stop playing’ event. When a new BP wants to play audio, it has to use ‘getallactorsofclass’ and send each of the other BPs a stop message, before playing it’s own audio.

Many other ways, but these two came to mind now… :slight_smile:

(Yes all the audio spawning and subtitles playing happens in the BP itself)

That seems like a good way to go about it.

But I still don’t know how I’d do that. Can I show you my BP so you can have a better understanding of what’s going on in it?

That’s my blueprint, in 3 separate screenshots.

So, I’m my ( imaginary ) BP, it looks like this:

I only used spawn sound events and the stop event, but you get the picture. Each BP needs to call the stop event in all the other BPs before it starts doing it’s thing…

Okay, that makes more sense to me. I’ll give it a go and report back.

Thank You.

I had a try by using the example you gave above but it does nothing. :frowning:

I did connect the ‘Play’ custom event to what the blueprint does.

But I don’t know how to stop playing the audio and the subtitles from the ‘Stop’ custom event.

The subtitles are just UMG’s being called so it sync’s with the audio. They’re ‘removed from parent’ to stop showing them.

Let’s rewind a bit :slight_smile:

You have a number of BPs. Each one of these, on overlap, knows how to start audio and subtitles.

I don’t see you starting audio in the pictures above, so I can’t tell you the specific way to stop that audio. But each method of playing audio, always has a way of stopping it before it’s finished playing.

So, each BP can start audio, it also need to be able to stop it. You have ( at least ) two custom events in the BP:

  1. OnBeginOverlap → starts the audio ( and subs )

  2. CustomEvent ( called maybe ‘Stop’ ) → stops the audio and subtitles started by this BP

Because each BP contains a Stop event, you can call it from any of the other BPs. That’s what the ‘GetAllActorsofClass’ is for. To find all the other BPs that might currently be playing audio, and ask them to stop, using the stop event.

So, 1) actually becomes:

  1. OnBeginOverlap → GetAllActorsofClass(MyBP) → Call the stop event on each one → Start my audio and subs

Does it make sense? :slight_smile:

Let’s rewind a bit :slight_smile:

You have a number of BPs. Each one of these, on overlap, knows how to start audio and subtitles.

I see you’re using PlaySoundAtLocation, which doesn’t have a way of stopping the sound. Why not try SpawnSoundAtLocation, which is just the same, but returns a link which can be assigned to a variable. Later you can use that variable with a Stop call, just like I did above.

So, each BP can start audio, it also needs to be able to stop it. You have ( at least ) two custom events in the BP:

  1. OnBeginOverlap → starts the audio ( and subs )

  2. CustomEvent ( called maybe ‘Stop’ ) → stops the audio and subtitles started by this BP

Because each BP contains a Stop event, you can call it from any of the other BPs. That’s what the ‘GetAllActorsofClass’ is for. To find all the other BPs that might currently be playing audio, and ask them to stop, using the stop event.

So, 1) actually becomes:

  1. OnBeginOverlap → GetAllActorsofClass(MyBP) → Call the stop event on each one → Start my audio and subs

Does it make sense? :slight_smile:

( The way you’ve coded your subtitles, you wont be able to kill them from the Stop event. Maybe just work with the audio for now, until you get it working, and then re-incorporate the subtitles. )

Incidentally, I should have called the custom event other than Stop. You might be getting it confused with the Stop node which halts the audio. You can call the red Stop custom event node anything you want obviously…

Oh right okay, I understand now. I’ll change a couple of things within the BP.

The way my BP is, is that upon an input action (which is R2) > ‘Play Sound At Location’ > ‘call Widgets that are subtitles’ until end. (Also, I’m controlling the force feedback upon the input action is ‘Released’ and Writing Trophy Progress/Achievement)

I didn’t use the built in Subtitle system because it doesn’t suit the way I’m wanting the subtitles to come across to the player. i.e. when I tried using it, I couldn’t control how long each subtitle stayed on screen, that’s the explanation for using this UMG method.

Ah, good, just come back if you get stuck. You’ll need to recode your subtitles to be ‘interruptable’. That’s not a special keyword, all I mean is, just like the sound, the subs need to stoppable in the middle of everything, because another BP could be starting it’s sound and subs…