I am currently trying to make a 2D unity game, and the goal is to break blocks.
To achieve this, the sprite uses a “hit point” system, then deletes it’s self when it hits zero. BUT, for some odd reason, Unity keeps the sprite loaded in the game view. It is gone in my scene view, so I know it is working. It just won’t disappear in my game view. I have tried searching for some sort of refresh for the SpriteRenderer component, but I can’t seem to find anything.
private void Start()
{
if (depthMultiplier == 0)
{
hitPoints = 3;
}
}
void OnMouseDown()
{
hitPoints -= 1;
Debug.Log(hitPoints);
if (hitPoints == 0)
{
Destroy(gameObject);
}
}
}
Code I am currently using
Sprites won’t go away in game view