It is good practice to recognize potential errors early on. I’m not familiar with your code or the course content, but I can help you identify the problem. NullReferenceExceptions basically means that the reference to the reference type you are trying to access is invalid, so you better catch it as follows:
It definitely looks like your UnitActionSystem hasn’t set it’s instance quite yet. This is known as a race condition. It happens when two competing initialization methods happen out of order. In this case, your UnitSelectedVisual is looking for the instance in UnitActionSystem, but the UnitActionSystem hasn’t run it’s code yet.
We should be initializing the UnitActionSystem in it’s Awake() method, which should always be ran before any of the Start() methods have run, regardless of the Script Operation order.
Paste in your UnitActionSystem’s Awake() and Start() methods, and we’ll take a look.
That’s interesting… there shouldn’t be a race condition here, as the UnitActionSystem.Awake() should always be running before any Start() methods…
Are you using Play Mode Options in the Project Settings | Editor section? With Singletons, it’s important to make sure that Reload Domain is ticked or the UnitActionSystem could detect that there is an instance when there is not really one there. It’s generally best NOT to use Enter Play Mode Options
Brian: You where absolutely right. I don’t know why or how, but the UnitActionSystem was missing from scene. I know I added it along with the course said to. Again thanks for your help.