Stopping sound from other BP when component overlapped doesn't work!


this is BP_cube1

this is BP_cube2 (the node at the very end is ‘stop’ target : audio component.)

I want to stop the sound playing from cube1 when I overlap the collision box of cube2. But it ain’t working. Is there something wrong with my BPs? help would be rly appreciated!

Same as in the previous thread of yours:

What is this a reference to? Creating an actor reference does not do much on its own, you need to point to an actual actor instance. We can’t see it in the script above.

Perhaps the editor does not understand which actor you mean? Place a Print String node after the Cast Failed pin and see if it prints.

I just put ‘actor’ in there. not really sure what to put in there. Seems like I need to put in something else! (kinda new to the engine, sorry)

I am a bit confused by the intent. Could you briefly describe how it’s supposed to work:

  • the player touches cube A - it changes material and then plays a sound, once
  • the player touches cube B - cube A stops playing sound?

How close am I?

yes that is how it is supposed to work. I want the music from cube1 to stop and change to music from cube2.

The cubes have no clue what is going on, and should stay this way. It’s the player that is the instigator here - I think it would be better if the player held onto the reference and was driving the logic.

  • in the cube actors:

Work in the DoOnce here if needed and handle the sound.

  • in the player who has a small sphere overlap they can touch the cubes with:

The sound will play in the cube we just touched and stop in the one we touched before; there can be any number of cubes and they do not know about each other’s existence - avoid creating hard references if you can.

I hope I got it right.

1 Like


sorry for my stupidness, why do I get error message on ‘stop’ here?

What is the message?


it might be an attempt to stop a sound that has yet to start playing, before the Song variable was Set above. Try this after False:

image

There’s probably another way, you could query whether this isPlaying and only stop if it is. But the above is probably fine here, too.

Thank you so much in advance trying to help me. Now everything works fine until I touch the second cube; music from cube1 keeps playing and music from cube2 doesn’t play at all. What did I do wrong?


This:

It was fine before:

Also it looks like those cubes are of different classes? Am I right? So is your plan to write the same script for every cube? How many are we going to have?

This should be 1 cube class, many cube instances, each with an editable sound variable. So each instance of the cube can play a different song and be reused many times. Otherwise, casting would become a nightmare, too.

But I may be assuming too much, do tell!

I deleted the second cube and made the set material and music as variable. now second music comes out but the first one doesn’t stop playing

My question stands, as above. I assumed the cubes are of the same class. Are they?

yes.

So what’s up with this:

Different names?

I used to have 2 cubes with different classes, but I deleted the second one above where you said this should be 1 cube class. And changed song to variable

Is the behavior you’re after?

yes! that but with do once.

So I’ve got this:

Note the Instance Editable Sound variable, so I can choose sounds for each cube:

The player script is as it was. It might be a good idea if the Sound is valid, too.


Not sure what is supposed to happen when you touch the same cube twice. It stops sounds.

hmm why would the first music not stop when I touch the second cube :frowning: