add unity project

add example for FSM
This commit is contained in:
2025-04-08 13:03:11 +02:00
parent 7e484e4831
commit 19a08085fe
81 changed files with 7741 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
using System;
using UnityEngine;
namespace DefaultNamespace.FSM
{
public class ChaseSystem : MonoBehaviour, IFiniteStateMachine
{
[SerializeField] private PlayerController _playerController;
private IState _currentState = null;
private void OnEnable()
{
_currentState = new IdleState(gameObject, _playerController, 60.0f);
}
private void OnDisable()
{
_currentState = null;
}
public void Update()
{
if (_currentState == null) return;
_currentState.Update(this);
}
public void SetState(IState state)
{
_currentState.Exit(this);
_currentState = state;
_currentState.Enter(this);
}
}
}