Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Audio Playing on ALL Clients

Discussion in 'Multiplayer' started by bdoom, Feb 21, 2016.

  1. bdoom

    bdoom

    Joined:
    Apr 13, 2013
    Posts:
    12
    Here's my code:
    Code (CSharp):
    1. public static void PlayUnitBattleSound()
    2.     {
    3.         //AudioClip[] clips = Resources.LoadAll<AudioClip>("Audio/BattleSounds");
    4.         // note sure if Resources.loadAll is faster than using an array.
    5.         string[] clipNames = { "blah", "no one can see this!!!"};
    6.         int randomClip = Random.Range(0, clipNames.Length);
    7.         AudioClip clip = Resources.Load<AudioClip>("Audio/BattleSounds/" + clipNames[randomClip]);
    8.         Debug.Log("Playing sound: " + clip.name);
    9.         AudioSource.PlayClipAtPoint(clip, Vector3.zero);
    10.  
    11.     }
    Anyone know why the audio plays on all clients?
     
  2. bdoom

    bdoom

    Joined:
    Apr 13, 2013
    Posts:
    12
    BUMP
     
  3. SuperNeon

    SuperNeon

    Joined:
    Mar 16, 2014
    Posts:
    85
    We need more info. Where is called the function PlayUnitBattleSound ?