How to cast an actor's all copies

Hello guys, I’m trying to make a speaker system right now that plays quotes. I’m casting to the speaker actor to play the sound. There are 4 speakers in the scene that should play the desired sound but only one of them plays it. How can I solve it? This is the code.

Hello and welcome to the forum.

The As Speaker variable can only reference one thing, your loop in BeginPlay is just overwriting the value set by previous iterations, leaving you with the last one found.

Save all the speakers in Begin Play (make your variable an array), and loop over them in the overlap event:

Also: If the Speaker doesn’t need to know what the sound is after it starts playing it, consider removing its Sound var and having Play Sound take the sound to play as a parameter, so you are not reaching in setting a variable on it before hand:

1 Like

Hi @silnarm, thank you so much. It worked flawlessly!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.