How can i synchronize music on multiplayer?

I start game as standalone and 2 screens. One screen hosts the game, and other one connects him by ip. Problem is that music starts to play when you login the server. As example if you create the server and wait 10 second the other player, other player’s music will be 10 seconds behind. How can i synchronize it ?


It is level BP

When you create the sound, you can roll out the parameters and set the “start time.”
If all you need is approximate sync, then you can receive the current play position from the server when you join, and pass that into the “Create Sound 2D” node.

If you need more accurate sync, then you need to create some actor whose job it is to send the position from the server on a timer, and receive it on the client, and skip ahead/back when it’s far off the mark, and slightly adjust playback pitch (rate) when you’re close, to match as precisely as possible.

In practice, getting within “ping time plus 100 milliseconds” is probably going to be reasonable, and won’t cause too much annoying wow/flutter/stutter in the playback. Trying to get better than that, might need task-specific C++ code, rather than trying to make it happen through gameplay/blueprint code.

1 Like

Thanks for your reply. Excuse being newbie on multiplayer but it is still same. What am i missing? Trying approximate sync.

You have to have the right value received already when you first start the music. The position is taken/copied right when the Play function is called, there’s no persistent link between the position and that input variable.

It looks to me like your local client will start the music before it receives the server’s playback position. You might want to make Current Play Position be OnRep replicated, and start the music in the first OnRep callback on the client, whereas you start it always on the server. (E g, “switch has authority” or similar.)