After updating my Brick.cs code to detect a win condition my bricks stopped working. Any Idea what would cause this. Everything was working fine up until the addition of the code in this section.
This is my Brick Script.
public class Brick : MonoBehaviour
{
public Sprite[] hitSprites;
private int timesHit;
private LevelManager levelManager;
public static int breakableCount = 0;
bool isBreakable;
// Use this for initialization
void Start ()
{
isBreakable = (this.tag == "Breakable");
if (isBreakable)
{
breakableCount++;
}
timesHit = 0;
levelManager = GameObject.FindObjectOfType<LevelManager>();
}
void OnCollisionEnter2D(Collision2D collision)
{
if (isBreakable)
{
HandleHits();
}
}
void HandleHits()
{
timesHit++;
int maxHits = hitSprites.Length + 1;
if (timesHit >= maxHits)
{
breakableCount--;
Destroy(gameObject);
}
else
{
Loadsprites();
}
}
void Loadsprites()
{
int spriteIndex = timesHit - 1;
if (hitSprites[spriteIndex])
{
this.GetComponent<SpriteRenderer>().sprite = hitSprites[spriteIndex];
}
}
void SimulateWin()
{
levelManager.LoadNextLevel();
}
}
Any suggestions would be appreciated. I really like what I’m working on here!
Also Running on Unity5 and VS. And will saving to OneDrive affect anything as far as loading times for assets.
SOLVED = Missed line and Typo.