19 lines
350 B
C#
19 lines
350 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class StateMachine : MonoBehaviour
|
|
{
|
|
private State currentState;
|
|
|
|
public void SetState(State newState)
|
|
{
|
|
currentState?.Exit();
|
|
currentState = newState;
|
|
currentState?.Enter();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
currentState?.Update();
|
|
}
|
|
} |