Type `State` is not recognised?





Hi Siddharth,

The class your have created is called state (first screenshot). In AdventureGame you then try to use it but refer to the type (line 8) as State. C# is case-sensitive, so state and State as class names are not the same.

The solution here is to edit your state.cs script, rename it to State on line 6. You should then also update the state.cs filename to reflect the same change, e.g. rename it to State.cs.

On a related note you have your variable StoryText with a captial ā€œSā€ as well, its quite important, and will invariably help you in the long run to stick to good naming conventions. Member variables(fields) typically use camelCase, classes and method named use PascalCase. By following these guidelines it will make your code a lot easier to read, example;

using UnityEngine;

public class State : MonoBehaviour
    [TextArea(14, 10)] [SerializeField] string storyText;

    public string GetStateStory()
        return storyText;

Please note, screenshots for code are not very useful. They tend to be more difficult to read, especially using mobile devices which require the user to constantly scroll back and forth. It also prevents those that offer their time to help you from just copy/pasting a part of your code back to you with a correction/suggestion. Please just copy/paste your code directly into your posts and then apply the code formatting characters both before and after it (see below). Screenshots are useful however for error messages and details from the Unity editor.

Hope this helps :slight_smile:

See also;