Weird inheritance error

Hi, I have a base GameType class where I made the Start function protected virtual.

So, in the base Start function I create an object of type gameLogicScript which is assigned to a protected variable so all children can acess it.

I have 2 child classes which inherit from GameType, in both I use the protected override keywords for the Start function, and then I call base.Start() in each of them.

The problem is, the gameLogicScript variable which gets initialised in the base class works for only one of the child classes. I use that variable in the Update method of each of the child classes and in 1 of them I get the console error “object reference not set to an instance of an object” but it works fine in the other child. I even tested it to make sure it is calling the parent start from within the child class where it does not work and everything is getting called correctly. It just seems like the value is not getting stored for some reason. It is incredibly weird. Does anybody have any experience with something like this?

For that kind of issues, it is necessary that you share the relevant code. Otherwise it is impossible to help, or we need to guess like crazy. As you pointed out, theoretically it should work.

Ah my fail. I had not originally had a base class for these and I forget to take all the variables from the script which were now in the parent. So it was re-declaring the variables in the child class which are then different than the parent! :stuck_out_tongue: