I have a static variable which holds the milliseconds since the start of the game (the score) and I want to increase it by a specific number once my player object collides with a “bonus point” object. I’ve already made the collider work, but when I try to increase it nothing happens.
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.CompareTag("Player"))
{
Score.scr += 100;
JewelExplosion();
Destroy(this.gameObject);
}
}
“Score” is the name of the file which contains the static variable “scr”.
Thank you.