ApplyLerp(Component targetComponent, ComponentData rightData, float factor) { Animator anim = (Animator)targetComponent; AnimatorData right = (AnimatorData)rightData; //fast asleep if ((this.sleeping && right.sleeping) || !anim.gameObject.activeInHierarchy) { return; } //waking up else if (this.sleeping) { right.Apply(targetComponent); } //going to sleep else if (right.sleeping) { this.Apply(targetComponent); } //totally awake else { //animation parameters int paramCount = anim.parameterCount; for (int i = 0; i < paramCount; i++) { this.animParams[i].ApplyLerp(right.animParams[i], factor, anim.parameters[i], anim); } //current state int layerCount = anim.layerCount; for (int layer = 0; layer < layerCount; layer++) { this.animStates[layer].ApplyLerp(right.animStates[layer], factor, layer, anim); } } }