Having a bit of trouble with my web build, i’ve only been using Unity a short time so possibly i’m missing something obvious… I checked responses to similar questions and it hasn’t shed any light on this for me.
There are essentially two problems:
-
My web build is missing a large plane which I use as a background. It was there in the previous build, now it is gone. Here is the old build:
http://www.jonweinel.com/games/sub_test_build01/sub_test_build01.html
and here is the new one:
http://www.jonweinel.com/games/sub_test_build02/sub_test_build02.html
As you can see, the background plane has gone. It’s still there in the editor. -
I have some code for the spikey enemies, which I have pasted below. It is suppose to have them shoot burst of 3 shots at different angles, and again, this works fine in the editor. Yet when I build it, they only fire the very first shot and none thereafter.
(as before, this is the build in question: http://www.jonweinel.com/games/sub_test_build02/sub_test_build02.html)
Here’s the code:
public float rotationSpeed = 10.0f;
private float autoFireIntroSpeed = 1f;
private float staggeredFireSpeed = 0.2f;
private float startAngle = 90;
private float angleStagger = 60;
private bool firstOnScreen = true;
private float autoFireSpeed = 2f;
public GameObject enemyBullet;
public AudioClip shotSound;
private bool enemyShooting = false;
public bool enemyActive = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// enemy is only active when visible. note this can cause problems if enemy casts a shadow or goes behind something obscuring it from view.
if (renderer.isVisible && enemyActive == false){
enemyActive = true;
enemyShooting = true;
gameObject.SendMessage("EnemyGuns");
}
// if enemy is active, it rotates
if (enemyActive == true){
transform.Rotate(new Vector3(rotationSpeed * Time.deltaTime,rotationSpeed * Time.deltaTime, rotationSpeed * Time.deltaTime));
}
}
void OnTriggerEnter(Collider col){
if(col.gameObject.tag == "Player"){
col.gameObject.SendMessage("HitWall");
}
if(col.gameObject.tag == "bullet"){
// you can only kill enemies you can see on screen
if (renderer.isVisible){
Debug.Log ("hitAnEnemy");
GameObject thePlayer = GameObject.FindGameObjectWithTag("Player");
thePlayer.gameObject.SendMessage("enemyKilled");
Destroy(gameObject);
}
}
}
IEnumerator EnemyGuns(){
if(enemyShooting == true){
//enemy gun shots
// if the enemy has only just appeared on screen there is a short pause before it starts shooting
if(firstOnScreen == true){
yield return new WaitForSeconds(autoFireIntroSpeed);
firstOnScreen = false;
}
// then regular shooting is established
GameObject newbullet;
Quaternion shotAngle1 = Quaternion.Euler(0,0,(startAngle + angleStagger));
newbullet = Instantiate(enemyBullet, new Vector3(transform.position.x, transform.position.y, transform.position.z), shotAngle1) as GameObject;
audio.PlayOneShot(shotSound);
//second shot
yield return new WaitForSeconds(staggeredFireSpeed);
GameObject newbullet2;
Quaternion shotAngle2 = Quaternion.Euler(0,0,(startAngle + (2 * angleStagger)));
newbullet2 = Instantiate(enemyBullet, new Vector3(transform.position.x, (transform.position.y), transform.position.z), shotAngle2) as GameObject;
audio.PlayOneShot(shotSound);
//third shot
yield return new WaitForSeconds(staggeredFireSpeed);
GameObject newbullet3;
Quaternion shotAngle3 = Quaternion.Euler(0,0,(startAngle + (3 * angleStagger)));
newbullet3 = Instantiate(enemyBullet, new Vector3(transform.position.x, (transform.position.y), transform.position.z), shotAngle3) as GameObject;
audio.PlayOneShot(shotSound);
// pause before next shots
yield return new WaitForSeconds(autoFireSpeed);
startAngle = (startAngle + (3 * angleStagger));
}
}
}