I’m trying to implement a system that takes the online/offline characters, and then changes their audio clip to something different in the level they should. I’ve been having some problems with FindGameObjectsWithTag only on the online part of the script. Here’s the relevant portion of the code:
if (Application.loadedLevelName != "Main Menu")
{
if (Application.loadedLevelName == levelToPlay)
{
levelToPlay = null;
if (Network.isServer || Network.isClient)
playingOnline = true;
players = GameObject.FindGameObjectsWithTag ("OnlinePlayer");problematic code
Debug.Log (players.Length); //this always returns 0.
if (players.Length == 0)
players = GameObject.FindGameObjectsWithTag ("OfflinePlayer");
for (int i = 0; i < players.Length; i++)
{
if (players *== null) break;*
-
else*
_ players*.audio.clip = (AudioClip)Resources.Load (nextTrack, typeof(AudioClip));*_
* }*
* }*