Static variables can be a little confusing to explain through text. So if you are a visual learner like me, here is an example of how static variables work, compared to non-static variables:
HOW STATIC VARIABLES WORK:
Lets say this is the starting state of the bricks and the brick class.
Lets say Brick 2 adds + 1 to the breakableCount
Then breakableCount updates in every brick AND the original class / template it was created from.
Now lets say that Brick 4 also adds +1 to breakableCount. It will update again everywhere.
It doesn’t have to be a Brick that updates breakableCount. Other Classes can update breakableCount by updating it direclty in the Class(Brick).
breakableCount will update in all locations still, even though we are editing the Class(Bricks), all the bricks themselves will also be updated!