Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [RequireComponent(typeof(Animator))]
- public class BodyAnimator : MonoBehaviour
- {
- protected Animator animator;
- [SerializeField] private BodyAnimationState _state;
- public BodyAnimationState state
- {
- get => _state;
- set
- {
- CallAnimation(value);
- _state = value;
- }
- }
- private Dictionary<BodyAnimationState, int> animationMap = new Dictionary<BodyAnimationState, int>
- {
- {BodyAnimationState.Standart, Animator.StringToHash("GoesToStandartTrigger")},
- {BodyAnimationState.PlayerGoesLeft, Animator.StringToHash("GoesLeftTrigger")},
- {BodyAnimationState.PlayerGoesUp, Animator.StringToHash("GoesUpTrigger")}
- };
- private void Start() => animator = GetComponent<Animator>();
- private void CallAnimation(BodyAnimationState callState) => animator.SetTrigger(animationMap[callState]);
- }
- public enum BodyAnimationState{Standart, PlayerGoesLeft, PlayerGoesUp}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement