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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Build is different than test

Discussion in '2D' started by avi12345, Mar 27, 2018.

  1. avi12345

    avi12345

    Joined:
    Mar 21, 2018
    Posts:
    4
    I am building a platformer where the color of a zone changes when a player enters it. This works fine for my test runs, but on my build, the color of the next zone over changes.

    Specifically, my zones are all Sprites in the Hierarchy, each with unique Tags of "Success" + the number of the zone. When I run on my build, the collision detector detects the zone number as 1 more than it should be.

    This is of my build
    Build.PNG

    This of my test
    test.PNG

    My scripts:

    Code (csharp):
    1.  
    2.     public class CollisionDetector2 : NetworkBehaviour {
    3.        void OnTriggerEnter2D(Collider2D other)
    4.        {
    5.           if (!isLocalPlayer)
    6.              return;
    7.           Debug.Log(other.tag);
    8.           if (other.tag.Substring(0, 7) == "Success")
    9.           {
    10.              if (isServer)
    11.             {
    12.                 GameObject.Find("GameController").GetComponent<ProgressTracker>    ().Collide(Int32.Parse(other.tag.Substring(7)));
    13.              }
    14.             else
    15.             {
    16.                 CmdNotifyCollide(Int32.Parse(other.tag.Substring(7)));
    17.              }
    18.           }
    19.        }
    20.  
    21.        void OnTriggerExit2D(Collider2D other)
    22.        {
    23.    
    24.           if (!isLocalPlayer)
    25.              return;
    26.           if (other.tag.Substring(0, 7) == "Success")
    27.          {
    28.             if (isServer)
    29.              {
    30.                 GameObject.Find("GameController").GetComponent<ProgressTracker>().Exit(Int32.Parse(other.tag.Substring(7)));
    31.             }
    32.              else
    33.             {
    34.                CmdNotifyExit(Int32.Parse(other.tag.Substring(7)));
    35.             }
    36.           }
    37.       }
    38.  
    39.        [Command]
    40.       void CmdNotifyCollide(int num)
    41.        {
    42.           GameObject.Find("GameController").GetComponent<ProgressTracker>().Collide(num);
    43.        }
    44.  
    45.        [Command]
    46.       void CmdNotifyExit(int num)
    47.        {
    48.          GameObject.Find("GameController").GetComponent<ProgressTracker>().Exit(num);
    49.        }
    50.     }
    51.  
    Code (csharp):
    1.  
    2.     public class ProgressTracker : NetworkBehaviour {
    3.  
    4.        public SyncListBool success = new SyncListBool();
    5.  
    6.        void Start()
    7.       {
    8.           success.Clear();
    9.           for (int i = 0; i < 8; i++)
    10.          {
    11.             success.Add(false);
    12.           }
    13.  
    14.           success.Callback = OnSuccessChange;
    15.        }
    16.  
    17.        public void Collide(int num)
    18.        {
    19.          if (!isServer)
    20.              return;
    21.  
    22.           //Debug.Log(num);
    23.           success[num - 1] = true;
    24.  
    25.        }
    26.  
    27.        public void Exit(int num)
    28.        {
    29.          if (!isServer)
    30.             return;
    31.  
    32.           success[num - 1] = false;
    33.        }
    34.  
    35.        public void OnSuccessChange(SyncListBool.Operation op, int index)
    36.        {
    37.          int total = 0;
    38.           for (int i = 0; i < 8; i++)
    39.          {
    40.             if (success == true)
    41.             {
    42.                 total += 1;
    43.              }
    44.          }
    45.  
    46.          if (total == 2)
    47.          {
    48.             NetworkManager.singleton.ServerChangeScene("SeniorProject3");
    49.           }
    50.  
    51.          if (success[index])
    52.           {
    53.                SpriteRenderer block = GameObject.Find("Success" + (index + 1)).GetComponent<SpriteRenderer>();
    54.                block.color = new Color32(104, 104, 104, 255);
    55.           }
    56.           else
    57.          {
    58.  
    59.                 SpriteRenderer block = GameObject.Find("Success" + (index + 1)).GetComponent<SpriteRenderer>();
    60.                block.color = new Color32(182, 182, 182, 255);
    61.  
    62.          }
    63.        }
    64.  
    65.     }
     
  2. Foodood

    Foodood

    Joined:
    Apr 26, 2015
    Posts:
    7
    Having the same issue here :/ it seems be a building issue and not a script issue
     
  3. avi12345

    avi12345

    Joined:
    Mar 21, 2018
    Posts:
    4
    This is a noob question, but what is the difference between a build and script issue?
     
  4. Foodood

    Foodood

    Joined:
    Apr 26, 2015
    Posts:
    7
    Script issues can mean something within the code you created. But a build issue can mean something went wrong when building/rendering the project.