I copied every bit of code in the “Manage Next States video”
//States
using System.Collections;
using System.Collections.Generic;
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;
}
}
//AdventureGame
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;
// 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.LeftArrow))
{
state = nextStates[0];
}
else if (Input.GetKeyDown(KeyCode.RightArrow))
{
state = nextStates[1];
}
textComponent.text = state.GetStateStory();
}
}
What the heck is null and why?