Added AI Unity project
Added FSM examples
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace AI.StateMachineBehaviours
|
||||
{
|
||||
public class TestStateBehaviour : StateMachineBehaviour
|
||||
{
|
||||
private static readonly int IS_EXIT = Animator.StringToHash("IsExit");
|
||||
|
||||
[SerializeField] private InputActionReference inputAction;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateEnter");
|
||||
inputAction.action.Enable();
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateExit");
|
||||
inputAction.action.Disable();
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateUpdate");
|
||||
|
||||
if (inputAction.action.triggered)
|
||||
{
|
||||
animator.SetTrigger(IS_EXIT);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateIK");
|
||||
}
|
||||
|
||||
public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateMove");
|
||||
}
|
||||
|
||||
public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateMachineEnter");
|
||||
}
|
||||
|
||||
public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
Debug.Log("TestStateBehaviour OnStateMachineExit");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d8920bea0824f22b41a06397cd8dd49
|
||||
timeCreated: 1776694487
|
||||
Reference in New Issue
Block a user