Hi,
I want that an object don’t get destroyed but just change the color.
I have modified my previous script where it got destroyed.
But it is still getting destroyed.
What is wrong?
private void OnCollisionEnter2D(Collision2D collision)
{
if (tag == "Breakable")
{
HandleHit();
}
}
private void HandleHit()
{
timesHit++;
int maxHits = hitSprites.Length + 1;
if (timesHit >= maxHits)
{
HitBlock();
Debug.Log("Hit");
}
else
{
//ShowNextHitSprite();
}
}
private void HitBlock()
{
Debug.Log("HitBlock");
PlayBlockDestroySFX();
//Destroy(gameObject);
GetComponent<SpriteRenderer>().color = hitColor;
TriggerSparklesVFX();
}