Hi All,
I’ve got an unusual error coming up that’s got me a bit stumped.
I can run the game fine, everything looks to function correctly but then on stopping the game I get errors.
First I get “Can’t remove Health (Script) because CombatTarget (Script) depends on it” followed by null reference exceptions as below:
NullReferenceException: Object reference not set to an instance of an object
RPG.Attributes.Health.GetFraction () (at Assets/Scripts/Attributes/Health.cs:91)
RPG.Attributes.HealthBar.Update () (at Assets/Scripts/Attributes/HealthBar.cs:15)
and also a couple of missing reference exceptions as below:
MissingReferenceException: The object of type ‘BaseStats’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[T] () (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:42)
RPG.Stats.BaseStats.CalculateLevel () (at Assets/Scripts/Stats/BaseStats.cs:110)
RPG.Stats.LevelDisplay.Update () (at Assets/Scripts/Stats/LevelDisplay.cs:20)
MissingReferenceException: The object of type ‘Health’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[T] () (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:42)
RPG.Attributes.Health.GetMaxHealthPoints () (at Assets/Scripts/Attributes/Health.cs:81)
RPG.Attributes.HealthDisplay.Update () (at Assets/Scripts/Attributes/HealthDisplay.cs:20)
Now I know this is because Health is being destroyed but I can’t figure out why Health is being destroyed when I stop the game.
There are 5 null reference exceptions and 5 enemies in my scene. I can add null checks in the methods but I still want to know why it’s being destroyed on finish haha.
TIA