Extreme tuning with more balls causes problems


Ive been going back to this course after ive been away for some time. now ive tried to tune the game so theres more balls, and you can loose balls until the last one. if that one goes past the paddle you lose, but ive found that when i play, if two or more balls seems to hit the same block at the same time, they all detract a block from the serialized field, so the game thinks theres fewer blocks in play than there actualy is.

the ballcounter is also bugged sometimes as it dont count all balls at the start some times. ive gone about the counter the same way as the blockcounter in the course

ive added debug so you can see that two different balls destroy the same block/brick


Hi Alex,

Welcome back! :slight_smile:

Does this happen in the same frame? If so, maybe you could add a bool to your Ball class, for example isDestroyed. Check the value of the bool in the OnCollision method and do not execute the code if the value of the variable is true. When the Destroy method gets called, set the bool to true.

In the Destroy method block, you could also add this line: gameObject.SetActive(false);.

Did this fix the issue?

See also:

hi, making a bool seemed to help with the problem. i already had gameObject.SetActive(false); in my script.

thanks for the help :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.