private static float Refresh(AnimatorManager animatorManager, float timeOutTimer) { const float epsilon = 0.0001f; if (!Input.anyKeyDown && Math.Abs(Input.GetAxis("Mouse X")) < epsilon && Math.Abs(Input.GetAxis("Mouse Y")) < epsilon && !animatorManager.GetBoolAnimator("talk")) { return(timeOutTimer); } // If the user is active but the state is still in timeout, walk back in screen. if (animatorManager.GetBoolAnimator("timeout")) { animatorManager.SetBoolAnimator("timeout", false); // Do something on activation after timeout, may be inserted later } // Allow for moving the avatar with controls instead of only with animations. if (!animatorManager.GetApplyRootMotionAnimator() && animatorManager.GetCurrentAnimatorStateInfoAnimator(0).IsName("idle")) { animatorManager.SetApplyRootMotionAnimator(true); } return(0f); }
/// <summary> /// Sequences the animations in AnimSequence. /// </summary> /// <param name="anims">{animation, length} pairs</param> /// <returns>yield</returns> private IEnumerator AnimatorWaiter(IEnumerable anims) { if (AnimSequence == null || _animatorManager.WalkedAway()) { yield break; } foreach (Pair <string, float> pair in anims) { if (!_animatorManager.GetBoolAnimator("talk")) { yield break; } _animatorManager.CrossfadeAnimator(pair.GetA(), 0.03f, -1); _animatorManager.SetBoolAnimator("loop", true); //Wait for a set amount of seconds before starting the other animation. yield return(new WaitForSeconds(pair.GetB())); _animatorManager.SetBoolAnimator("loop", false); } }