Score & Lives not resetting on restart of game

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

You probably just need a reference to this class and to call NewGame(), which only appears to be called ONCE in this class.

This class also seems to have a broken or mis-implemented live-forever declaration (the DontDestroyOnLoad() ) since it is actually lacking any facility to prevent more than once instance of it existing at a time.

You may want to review how to make a GameManager, and there are plenty of youtubes.

Alternately, here are two possible approaches:

ULTRA-simple static solution to a GameManager:

OR for a more-complex “lives as a MonoBehaviour” solution…

Simple Singleton (UnitySingleton):

Some super-simple Singleton examples to take and modify:

Simple Unity3D Singleton (no predefined data):

Unity3D Singleton with a Prefab (or a ScriptableObject) used for predefined data:

These are pure-code solutions, do not put anything into any scene, just access it via .Instance!

If it is a GameManager, when the game is over, make a function in that singleton that Destroys itself so the next time you access it you get a fresh one, something like:

public void DestroyThyself()
{
   Destroy(gameObject);
   Instance = null;    // because destroy doesn't happen until end of frame
}
2 Likes