Code not working when I build and Run

So I created a “boss” enemy that loads another level upon being destroyed. This code is stored inside of a game controller object. The effect works fine when I play the game in editor, but when I build and attempt to run the game, My bullets seem to have no effect on the boss.

I checked the collisions, my bullets have rigid bodies and box colliders, it also is checked as a trigger. I could upload code but it is spread among three different scripts. So my question is, are there any pitfalls to be aware of when compiling code in unity? Is it reseting any values, or grabbing old copies of a script? Thanks in advance.

Code that controls the “Crab Boss”
Note the call to Gamecontroller.Lives

var score : int; 
var health : int;



var  explosionprefab : GameObject; 


var FireFreq : float ;

var bulletprefab : GameObject;

private var lastShot : float; 





function Update () {


 
if (Time.time > lastShot + FireFreq){
	Shoot();
}


}

function Shoot() {
	

	
	lastShot = Time.time;
	
	Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(0, -20,0) ) );
	Instantiate (bulletprefab, transform.position, transform.rotation);
	Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(0, 20,90) ) );
	

}


function OnTriggerEnter (  otherobject : Collider)
{
	

	

if (otherobject.tag == "PlayerBullet")
	 {
		 if (Gamecontroller.crabturret == 0)
		 {
				health -= 1; 
				
				if (health <1){
					Gamecontroller.totalEnemies -= 1;
				
					Instantiate (explosionprefab, transform.position, Quaternion.identity);
					Destroy(gameObject);
				 }
			}
	}

}

GameController Code

private var Level : int;
var Player : GameObject; 


static var totalEnemies : int;
static var Lives : int = 3;

var powerupprefab : GameObject;
static var powerup : GameObject ;
static var GameOver : boolean;
static var isWin : boolean;

// for the boss crabturret
static var crabturret  : int;

var enemies : GameObject[];
var guiSkin : GUISkin;
private var SpawnGrid; 


function Awake(){
Lives = 3;
GameOver = false;
powerup = powerupprefab; 
totalEnemies = 1; 
 isWin  = false;
 crabturret = 1;
DontDestroyOnLoad(this);
 
 
 SpawnGrid = new Array();
 SpawnGrid[0]  = new Array(Vector3(-27,114,15), Vector3(-29,114,15) , Vector3(-31,114,15) , Vector3(-33,114,15)    );
 SpawnGrid[1]  = new Array(Vector3(-27,114,13), Vector3(-29,114,13) , Vector3(-31,114,13) , Vector3(-33,114,13)    );
 SpawnGrid[2]  = new Array(Vector3(-27,114,11), Vector3(-29,114,11) , Vector3(-31,114,11) , Vector3(-33,114,11)    );
 SpawnGrid[3]  = new Array(Vector3(-27,114,9), Vector3(-29,114,9) , Vector3(-31,114,9) , Vector3(-33,114,9)    );

Instantiate(Player, Vector3(-43, 114, 4.5), Quaternion.Euler(0,180,0));

}

function Update () {
	if (totalEnemies == 0){
	isWin = true;
	//levelEnd();
	}

}


function levelEnd(){
	Level += 1;


	if (Level == 1){
		
		isWin = true;
		yield WaitForSeconds(1);
		
		
	}
	
		
}




function Respawn(){
	
	yield WaitForSeconds(1);
	Instantiate(Player, Vector3(-43, 114, 4.5), Quaternion.Euler(0, -180,0));
}

function OnGUI()
{
	GUI.skin = guiSkin;
	
	if (GameOver == true){
	
	if  (GUI.Button ( Rect ( Screen.width / 2 -140, 100, 300, 100), "Restart" ))
	{
		Application.LoadLevel(0);
	}
	
	}
	
	if (isWin)
	{
		GUI.Label (Rect ( Screen.width / 2 -140, 100, 300, 100), "You Win" );
		Application.LoadLevel("sh_l1"); //sky hawks test level
	}
}

Things To Check:

  1. Are all your levels added into the build? File → Build Settings → Scenes In Build

  2. Does anything else happen when you hit the boss with a bullet? Does his health visually decrease? Does a death animation play? Or does it just load the level once he’s dead?

Try adding in some sort of visual or audio effect that lets you know your “hitting the boss” code works

Will Do.

  1. All of the levels are in the build settings

  2. So far, the boss triggers an explosion, at which point another level is loaded after waiting some seconds. The GUI Also displays “You Win”

None of this happens when I run the code after building. It DOES however work in the “In Editor” play test. Is there any case why this would happen? Thanks for your help.

Update:

I just noticed this in my error console:

“Couldn’t copy player scene into data folder… Assets/Scenes/sh_1.unity”

So it looks like a build error. I saw someone with a similar issue on these forums, but I’m not sure how that problem was solved. Has this happened to anyone else?

Also getting this error: Where should i look for troubleshooting? Thanks:

Assets/Standard Assets/Scripts/CombineChildren.cs(27,25): warning CS0436: The type `MeshCombineUtility' conflicts with the imported type `MeshCombineUtility'. Ignoring the imported type definition