Problem with getting the code to run: " An object reference is required for the non-static field, method or property 'State.GetStateStory()' "

Hi Jake, welcome to the community :slight_smile:

Your error is because you are trying to access the method, GetStateStory, via the class State rather than an instance of it.

You have declared a variable, startingState but are not using it. You also have currentState.

From memory, the variable you have called currentState was called state in the course, which is probably where your confusion has come from.

Change this line;

textComponent.text = State.GetStateStory();

to

textComponent.text = currentState.GetStateStory();

Also, please apply the code formatting characters when copy/pasting your code into the forum.

Hope this helps. :slight_smile:


See also;