Download

Play Sound replication

Hi, I’m using the Play Sound Attached function when a player presses a key on my Blueprint, but it’s not replicated. Why? Only the player who pressed that key can hear the sound.

Yeah as far as I know there just isn’t replication of sounds.

What you might be able to do (though it probably won’t sync that well) is just replicate a variable to tell remote clients that a sound was played, so that you can manually play it on the client in those instances. I haven’t tried this, but it’s something I’m keen to do as I’d love to add multiplayer support to my VR audiobook player.

Yes, but how can I play the same Sound to all the clients?

I’m assuming the sound exists as an asset in the game, in which case you’d just do it normally.

If not, you’ll need to set up some sort of process for the host to stream the audio to clients, which is probably a lot of work. I haven’t looked into that at all so I really couldn’t say how to approach it.

I know the sound system does feature streaming now, so there’s that.

I would do this by using a Custom Event in the blueprint that you set to MultiCast. Then it would be replicated to all clients.
You could take a look at Epics official tutorial on replication and it would go through this in a good way! If none else has give a more deep explanation in a while I could give you a short tutorial. I’m just in a bit of a hurry atm so I can write a long post :slight_smile:

I need something more specific, because this isn’t something complicated, and maybe someone can do it, so I’m waiting other replies.

This is how I would have done it:

This will play the sound on all clients. It is replicated through the Custom Event that will fire for all players and play the sound. It is using the MultiCast option of the Custom Event!

Didn´t use the play sound attached, but the procedure is pretty much the same.

Yep, this is exactly what I was getting at.

@Scienziatogm - so does the SoundWave also exist on the clients or not? If it does, just use Sparven’s method. If not… you’ll need a different solution, more in line with what I mentioned before (e.g., sending the sound file itself to the clients, most likely in small chunks so it can be streamed as it downloads).

I did what you said, but only the dedicated server can emit sounds.

Yeah, if he can use my method it is easy as a pie. But if he wants to stream the sounds, then he is in for a world of pain I think before he gets the desired result.

Are you sure that you are using the Switch has Authority node aswell to check that the server is the owner? If so then it would replicate to all players.
The main problem is that using my method the only way the sound can go is Server -> Clients. So it should play on all clients. Are you sure that you are using a Dedicated server btw? If you can play the game and hear the sounds on the server then you are using a Listen Server instead. The dedicated would only have a command client.

Yes I’m using a Listen server because when I start the Dedicated Server, I get this:

And if I try to connect, I get this:

I´m really not your man to solve those errors atm. But try create a new thread with the logs and I´m sure someone else can help you out!

Ok. Thanks for the help. I opened another topic for that problem (Server build problem - C++ Gameplay Programming - Unreal Engine Forums).

No problems!

Now the Dedicated Server works, but the audio system doesn’t …

It’s amusing how the engine apparently has issues with the simplest of tasks, such as replicating a sound. Could anyone kindly shed light on this?