Lecture 75 (Smarter maxHits Logic) Challenge

This was my solution, if you use gameObject and gameObject.name, you seem to get the same response. I went with .name because it seemed more correct.

private void ShowNextHitSprite()
{
    int spriteIndex = timesHit - 1;
    if (hitSprites[spriteIndex] != null)
    {
        GetComponent<SpriteRenderer>().sprite = hitSprites[spriteIndex];
    }
    else
    {
        Debug.LogError("Block sprite is missing from array inside of - " + gameObject.name);
    }
}

Privacy & Terms