- Home /
Question by
QuietVenom · Dec 10, 2016 at 06:03 PM ·
c#unity 5beginner
[Help] hey i'm just a beginner... Problem with WEB GL build
So i'm programming a block breaker game and i'm already finished. Ican play without a problem on Unity but once i build it and run it for WEB GL the game won't let me break the blocks.
Please help!!!
http://gamebucket.io/game/72227b07-2e5e-47a1-b80d-606d7facb5be
This is my code for the block:
using UnityEngine;
using System.Collections;
public class Brick : MonoBehaviour {
public AudioClip crack;
public Sprite[] hitSprites;
public static int breakableCount = 0;
public GameObject smoke;
private int timesHit;
private LevelManager levelmanager;
private bool isBreakable;
// Use this for initialization
void Start () {
isBreakable = (this.tag == "Breakable");
// Keep track of breakable bricks
if (isBreakable){
breakableCount++;
}
timesHit = 0;
levelmanager = GameObject.FindObjectOfType<LevelManager>();
}
// Update is called once per frame
void Update () {
}
void OnCollisionExit2D (Collision2D col){
AudioSource.PlayClipAtPoint (crack, transform.position,0.25f);
if (isBreakable){
HandleHits();
}
}
void HandleHits (){
timesHit++;
int maxHits = hitSprites.Length + 1;
if(timesHit >= maxHits){
breakableCount--;
levelmanager.BrickDestroyed();
Puff ();
Destroy(gameObject);
} else{
LoadSprites();
}
}
void Puff (){
GameObject smokePuff = Instantiate (smoke,transform.position,Quaternion.identity) as GameObject;
smokePuff.GetComponent<ParticleSystem>().startColor = gameObject.GetComponent<SpriteRenderer>().color;
}
void LoadSprites () {
int spriteIndex = timesHit - 1;
if (hitSprites[spriteIndex] != null){
this.GetComponent<SpriteRenderer>().sprite = hitSprites[spriteIndex];
} else {
Debug.LogError ("Brick Sprite Missing");
}
}
//TODO remove this method once we can actually win
void SimulateWin (){
levelmanager.LoadNextLevel();
}
}
Comment