public void SetAnimatorValues(MonkeyAnimations.BodyRegion region = MonkeyAnimations.BodyRegion.None, MonkeyAnimations.Animation animation = MonkeyAnimations.Animation.None) { //set integer for corresponding region animator.SetInteger(MonkeyAnimations.GetAnimationIntParmeter(region), (int)animation); //stop existing lerp routine if (activeLayerRoutines.ContainsKey(region)) { StopCoroutine(activeLayerRoutines[region]); activeLayerRoutines.Remove(region); } //for any applied region, start layer weight routine if (region != MonkeyAnimations.BodyRegion.None) { if (animation != MonkeyAnimations.Animation.None) { activeLayerRoutines.Add(region, StartCoroutine(LayerLerpRoutine(region, 1, .25f))); } else { activeLayerRoutines.Add(region, StartCoroutine(LayerLerpRoutine(region, 0, .25f))); } } }
public Arm(Actor pActor, MonkeyAnimations.BodyRegion pRegion, InControl.PlayerAction targetInput) { actor = pActor; region = pRegion; inputToWatch = targetInput; PushArmState(new ArmNormalState(), "Initialization of " + Enum.GetName(typeof(MonkeyAnimations.BodyRegion), region) + "arm"); }
public IEnumerator LayerLerpRoutine(MonkeyAnimations.BodyRegion region, float target, float time) { //get starting weight float startWeight = animator.GetLayerWeight((int)region); //start current time proportionately to start weight float currentTime = time * (1 - Mathf.Abs(target - startWeight)); //lerp til completion while (currentTime < time) { currentTime += Time.deltaTime; animator.SetLayerWeight((int)region, Mathf.Lerp(startWeight, target, currentTime / time)); yield return(new WaitForEndOfFrame()); } }