I keep getting an error on nextStates on VS, sayinh that “Cannot Apply Indexing to an expression of type object”. I have the same code as in your examples. How can i fix this?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour
{
[SerializeField] Text textComponent;
[SerializeField] State startingState;
State state;
// Use this for initialization
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];
}
}
}