void StanceManage() { camEuler = playerCam.GetCamEuler(); transform.localEulerAngles = new Vector3(0f, camEuler.y, 0f); float lerpFactor = animLerpFactor * Time.deltaTime; float pitch = playerCam.getPitch(); if (Input.GetKeyDown(KeyCode.Tab)) { if (gp.query.currentStance == ActionQuery.Stance.OFFENSIVE) { gp.query.currentStance = ActionQuery.Stance.CHILL; } else if (gp.query.currentStance == ActionQuery.Stance.CHILL) { gp.query.currentStance = ActionQuery.Stance.OFFENSIVE; } } if (currentStance != gp.query.currentStance) //runs once per stance swap { currentStance = gp.query.currentStance; switch (gp.query.currentStance) { case ActionQuery.Stance.CHILL: playerCam.camComponent.fieldOfView = 80; break; case ActionQuery.Stance.OFFENSIVE: break; case ActionQuery.Stance.ANIMATED: break; default: break; } } float posBlend = 1f; float negBlend = 0f; if (currentlyEquipped != null) { currentlyEquipped.AnimatorUpdate(animator); } switch (currentStance) //runs every frame of stance { case ActionQuery.Stance.CHILL: negBlend = Mathf.Lerp(animator.GetLayerWeight(2), 0, lerpFactor); animator.SetLayerWeight(2, negBlend); ChillStance(); break; case ActionQuery.Stance.OFFENSIVE: posBlend = Mathf.Lerp(animator.GetLayerWeight(2), 1, lerpFactor); animator.SetLayerWeight(2, posBlend); OffensiveStance(); break; case ActionQuery.Stance.ANIMATED: break; default: break; } for (int i = 3; i < animator.layerCount; i++) { if (i == (int)currentEquipLayer && currentStance == ActionQuery.Stance.OFFENSIVE) { float blend = Mathf.Lerp(animator.GetLayerWeight(i), 1, lerpFactor); animator.SetLayerWeight(i, blend); } else if (i == (int)currentEquipLayer) { animator.SetLayerWeight(i, negBlend); } else { float blend = Mathf.Lerp(animator.GetLayerWeight(i), 0, lerpFactor); animator.SetLayerWeight(i, Mathf.Lerp(animator.GetLayerWeight(i), 0, blend)); } } animator.SetFloat("pitch", pitch); }