Files
beyond/Assets/Scripts/Invector/vAnimatorResetInput.cs
2024-11-20 15:21:28 +01:00

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);
}
}