Good afternoon, I can’t seem to be able to get the from the starting state to any of the other states. Room 1 and such.
My code appears correct. The elements and objects appear to be assigned correctly. I have tried every solution I found on the forum and the udemy course page.
Here is my code. I hope someone can help me out. Really want to continue the course.
using UnityEngine;
[CreateAssetMenu(menuName = “State”)]
public class State : ScriptableObject
{
[TextArea(14, 10)] [SerializeField] string storyText;
[SerializeField] State[] nextStates;
public string GetStateStory()
{
return storyText;
}
public State[] GetNextStates()
{
return nextStates;
}
}
using UnityEngine;
using UnityEngine.UI;
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];
}
textComponent.text = state.GetStateStory();
}
}