Hello compilation Error

Please I am getting this error, i have been stuck here

NullReferenceException: Object reference not set to an instance of an object
AdventureGame.Start () (at Assets/Scripts/AdventureGame.cs:20)

public class AdventureGame : MonoBehaviour
{
[SerializeField] Text textComponent;
[SerializeField] State startingState;

State state;


// Start is called before the first frame update
void Start()
{
    state = startingState;
    textComponent.text = state.GetStateStory();
    
}

// Update is called once per frame
void Update()
{
    ManageState();
}

private void ManageState()
{
    var nextStates = state.GetNextStates();
    if(Input.GetKeyDown(KeyCode.Alpha1))
    {

        state = nextStates[0];

    }
     else if
   
    (Input.GetKeyDown(KeyCode.Alpha2))


    {

        state = nextStates[1];
    }

This might be because there is no state assigned, so check if you have a State scriptable object assigned to the Starting State parameter.
image

Hello Thank you

But i have introduction state and it is still displaying the error.

Ok I figured it out thank you so much

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

Privacy & Terms