void GetCurrentState() { AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0); foreach (Behaviors nBehavior in behList) { if (stateInfo.IsName(nBehavior.animationName)) { int i = (int)stateInfo.normalizedTime; if (CurrentBehavior != nBehavior.Behavior) { if (stateInfo.normalizedTime >= i + 0f && stateInfo.normalizedTime <= i + 0.1f) { CurrentBehavior = nBehavior.Behavior; break; } } if (CurrentBehavior == nBehavior.Behavior) { break; } } } }
void ChangingAnimation() { if (currentBehavior != nextBehavior) { enemyBehContr.animator.ResetTrigger(FindTriggerAnimation(currentBehavior)); currentBehavior = nextBehavior; enemyBehContr.animator.SetTrigger(FindTriggerAnimation(nextBehavior)); } }
string FindTriggerAnimation(EnemyBehaviorList behavior) { var Behaviors = enemyBehContr.behList; foreach (var nBehavior in Behaviors) { if (nBehavior.Behavior == behavior) { return(nBehavior.triggerName); } } return(""); }
void GetNexAnimationBehavior() { AnimatorStateInfo StateInfo = enemyBehContr.animator.GetNextAnimatorStateInfo(0); var Behaviors = enemyBehContr.behList; foreach (var nBehavior in Behaviors) { if (StateInfo.IsName(nBehavior.animationName)) { nextBehavior = nBehavior.Behavior; break; } } }
void GetNextBehavior() { nextBehavior = enemyBehContr.CurrentBehavior; }
void Start() { animator = GetComponent <Animator> (); CurrentBehavior = EnemyBehaviorList.Idle; }