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!
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.
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.
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.
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?
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.
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