Files
real-shooter/Assets/Scripts/Animators/Leonid Animator/Bot/BotLocomotion.cs
2022-05-18 00:21:35 +07:00

40 lines
1.3 KiB
C#

using UnityEngine;
namespace Animators.Leonid_Animator.Bot
{
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(AnimatorHandler))]
[RequireComponent(typeof(MovementController))]
[RequireComponent(typeof(NPC))]
public class BotLocomotion : MonoBehaviour
{
private Vector3 _moveDirection;
private AnimatorHandler _myAnimatorHandler;
private MovementController _movementController;
private NPC _npc;
private NpcBodyState _crouchBuffer = NpcBodyState.Standing;
private void Start()
{
_myAnimatorHandler = GetComponent<AnimatorHandler>();
_movementController = GetComponent<MovementController>();
_npc = GetComponent<NPC>();
_myAnimatorHandler.Initialize();
}
private bool CrouchPressed(NpcBodyState state)
{
if (_crouchBuffer == state) return false;
_crouchBuffer = state;
return true;
}
public void UpdateAnimatorValues()
{
var movementDir = _movementController.Velocity;
_myAnimatorHandler.UpdateAnimatorValues( Mathf.Clamp01(movementDir.magnitude), 0,
false, CrouchPressed(_npc.NpcBodyState.State), _npc.IsFiring);
}
}
}