Search Unity

Network Synchronized AudioSource

Discussion in 'Multiplayer' started by Zullar, Sep 2, 2015.

  1. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    I am working on a multiplayer top-down action RPG. Here's an example video.


    My question is what is the best way to play networked sound effects. Currently I have a static list of every sound clip. Then I call a RPC with the integer index of the sound clip to play using AudioSource.PlayOneShot(clipList[index]). This works just fine. But when I want to do other things like change volume, play a looped clip using AudioSource.clip, AudioSource.loop=true, AudioSource.Play(), terminate a looped clip via AudioSource.Stop(), or if I wanted to have 2 looping clips at the same time, then it becomes a little trickier to manage this all over the network.

    Ideally I'd like for a networked AudioSource component that synchronizes on the clients whatever is happening on the server. Is there a proper/clean way to managed synchronized networked audio? If there is no easy built-in way to manage this and the proper way to do this is via RPC's then just let me know. Thanks in advance.