Following along with the lecture to check for a null hitSprite
, I’m encountering a strange issue that I’m confused by.
After removing all the damage sprites from my block instance, when playing the game I will get the Debug.LogError()
message, but the sprite of the block changes. I’m not sure why the sprite changes since the array is empty…
Here is my code:
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 [" + gameObject.name + "].");
}
}
And a screenshot of my Unity:
Any ideas what might be causing the error and non-existent sprite to be shown?