using System; using UnityEngine; namespace DefaultNamespace.FSM { public class ChaseSystem : MonoBehaviour, IFiniteStateMachine { [SerializeField] private IState _defaultState; [SerializeField] private PlayerController _player; private IState _currentState = null; private void Awake() { // _currentState = _defaultState; // isn't working, because an interface can't be serialized by the Unity Serializer _currentState = new IdleState(gameObject, _player, 60.0f); } private void Start() { _currentState?.Enter(this); } private void Update() { // if (_currentState == null) return; _currentState?.Update(this); } public void SetState(IState state) { _currentState.Exit(this); _currentState = state; _currentState.Enter(this); } } }