37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class vAnimatorResetInput : StateMachineBehaviour
|
|
{
|
|
private static readonly int InputHorizontal = Animator.StringToHash("InputHorizontal");
|
|
private static readonly int InputVertical = Animator.StringToHash("InputVertical");
|
|
private static readonly int InputMagnitude = Animator.StringToHash("InputMagnitude");
|
|
|
|
public bool onEnter;
|
|
public bool onExit;
|
|
|
|
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
if (onEnter)
|
|
{
|
|
ResetInput(animator);
|
|
}
|
|
}
|
|
|
|
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
if (onExit)
|
|
{
|
|
ResetInput(animator);
|
|
}
|
|
}
|
|
|
|
private void ResetInput(Animator animator)
|
|
{
|
|
animator.SetFloat(InputHorizontal, 0f);
|
|
animator.SetFloat(InputVertical, 0f);
|
|
animator.SetFloat(InputMagnitude, 0f);
|
|
}
|
|
}
|