Advertisement
This is comment for paste
Serialized AnimatorControllerParameter
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use case:
- using UnityEngine;
- using Sirenix.OdinInspector;
- using zORgs;
- using zORgs.Utilities;
- using Parameter = zORgs.Utilities.AnimatorControllerParameter;
- [RequireComponent(typeof(Animator))]
- public class BasicLocomotionInterface_v2 : MonoBehaviour
- {
- [HorizontalGroup("Parameters")]
- [BoxGroup("Parameters/Move")]
- public Parameter MoveZ;
- [BoxGroup("Parameters/Move")]
- public Parameter IsMoving;
- [BoxGroup("Parameters/State")]
- public Parameter Grounded;
- [BoxGroup("Parameters/State")]
- public Parameter Jump;
- [BoxGroup("Parameters/State")]
- public Parameter FreeFall;
- [BoxGroup("Aim")]
- public int _aimingLayerIndex;
- [BoxGroup("Aim")]
- public Parameter Empty;
- [BoxGroup("Aim")]
- public Parameter Aim;
- [BoxGroup("Aim")]
- public Parameter Rifle;
- private Animator _animator;
- private void Awake()
- {
- _animator = GetComponent<Animator>();
- }
- public void SetForwardSpeed(float value)
- {
- _animator.SetParameter(MoveZ, value);
- _animator.SetParameter(IsMoving, value != 0f);
- }
- public void SetGrounded(bool value) => _animator.SetParameter(Grounded, value);
- public void SetJump(bool value) => _animator.SetParameter(Jump, value);
- public void SetFreeFall(bool value) => _animator.SetParameter(FreeFall, value);
- [Button]
- public void StartAiming()
- {
- this.Tween(v => _animator.SetLayerWeight(_aimingLayerIndex, v), 0, 1, .1f);
- _animator.SetParameter(Aim, true);
- }
- [Button]
- public void StopAiming()
- {
- this.Tween(v => _animator.SetLayerWeight(_aimingLayerIndex, v), 0, 1, .1f);
- _animator.SetParameter(Aim, false);
- }
- [Button]
- public void RifleEquipped()
- {
- this.Tween(v => _animator.SetLayerWeight(_aimingLayerIndex, v), 0, 1, .1f);
- _animator.SetParameter(Rifle, true);
- }
- [Button]
- public void UnEquip()
- {
- this.Tween(v => _animator.SetLayerWeight(_aimingLayerIndex, v), 1, 0, .25f);
- _animator.SetParameter(Rifle, false);
- _animator.SetParameter(Rifle, false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement