Well another question from my side :-
private void OnCollisionEnter2D()
{
if (tag == "Breakable")
{
HandleHits();
}
}
private void HandleHits()
{
currentHits++;
int maxHits = hitSprites.Length + 1; // ?_?
if (currentHits >= maxHits)
{
DestroyBlock();
ParticleWhenBlockBreak();
}
else
{
ShowNextSprite();
}
}
In the new maxHits logic, we initialized maxHits variable inside the HandleHits()
function which is called whenever the ball collides with a block. But my doubt is whenever the ball will collide with a block maxHit should get some value by hitSprites.Length + 1
, but when the ball again collides with the same block, again maxHit should get the same value again n again till infinity as this line int maxHits = hitSprites.Length + 1;
will again execute.
But everything’s going right…why??