I think here’s a bug in the code because the result depends on whose “OnCollisionEnter” gets called first:
If the Player’s OnCollisionEnter gets called first, it detects that the obstacle’s tag is not “Hit”, and thus increase its score. The obstacle’s OnCollisionEnter gets called next and changes its tag to “Hit”.
OTOH, if the obstacle’s OnCollisionEnter gets called first, it changes its own tag to “Hit”, then the Player’s OnCollisionEnter gets called, and it detects that the obstacle’s tag is “Hit”, thus it doesn’t increase the score.
Is this correct?