36 lines
882 B
C#
36 lines
882 B
C#
using UnityEngine;
|
|
|
|
public class AnimationBoolEvent : MonoBehaviour
|
|
{
|
|
[Tooltip("If you won't declare the animator don't worry because it will automatically get as the animator the animator that this script is attached to.")]
|
|
[SerializeField] private Animator _animator;
|
|
[SerializeField] private string _boolName;
|
|
public bool StartAtPlay;
|
|
|
|
private void Start()
|
|
{
|
|
if (_animator == null)
|
|
{
|
|
_animator = GetComponent<Animator>();
|
|
}
|
|
if (StartAtPlay)
|
|
{
|
|
SetBoolTrue();
|
|
}
|
|
}
|
|
|
|
public void SetBoolTrue()
|
|
{
|
|
_animator.SetBool(_boolName, true);
|
|
}
|
|
|
|
public void SetBoolFalse()
|
|
{
|
|
_animator.SetBool(_boolName, false);
|
|
}
|
|
|
|
public void SetPlayerAnimator()
|
|
{
|
|
_animator = PlayerManager.GetInstance()._PlayerMovement._CharacterAnimator;
|
|
}
|
|
} |