Score wasnt updating from scene to scene?

so while trying to challenge myself to write the code on my own, i happen to instantiate the gamestatus variable on the Start() method instead of OnCollisionEnter2D() .
However, after winning a lvl i noticed my score stopped updating even after hitting blocks.
After rewatching the course, i noticed the mistake i made, and fixed it by calling

        status = FindObjectOfType<GameStatus>();

inside the OnCollisionEnter2D() method.
it works fine, but i dont understand the logic behind it, According to what i know , the Start() method is called before the OnCollisionEnter2D() one.
I hope someone enlighten me on the subject.

Hi,

Welcome to our community! :slight_smile:

Theoretically, if you didn’t load a new scene and if you assigned the returned reference to the instance variable, your approach with the Start method should have worked.

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

Privacy & Terms