ObjectReferenceException: Object reference not set to an instance of an object

Hi Ben. Whenever I call state.GetStateStory() or startingState.GetStateStory(), I get the following error code:

ObjectReferenceException: Object reference not set to an instance of an object

I’ve experimented, and if I run the line Debug.Log(startingState), it invariably logs Null. So somehow I’m not succeeding in getting startingState to refer to Starting State. I’d be grateful for help – I’m quite stumped.

It took about 90 minutes, but I got it sorted! I needed to click “Game” in the hierarchy in the Unity window and drag Starting State into the startingState property.

My repeated mistake had been to click AdventureGame (my C# script in the assets area) and assign Starting State to its startingState property. Which seems to accomplish precisely nothing.

Funny . . I had done the correct thing in an earlier lecture, and somehow I managed to undo it later on without realizing not? I’m not sure how that happened.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms