void UpdateIK(IKLookAt ik) { if (ik == null) return; animator.SetIKPositionWeight(ik.IKGoal, ik.Weight); Vector3 curTarget; if (ik.Target == null) { curTarget = targetPoint; } else { curTarget = ik.Target.transform.position; } animator.SetIKPosition(ik.IKGoal, curTarget); }
IEnumerator StopPointing(float duration, IKLookAt ik) { yield return new WaitForSeconds(duration); ik.Elapsed = 0f; //animator.SetInteger("Point", 0); ik.Active = false; ResumeIdling(); yield return null; }
void OnAnimatorIK() { if (leftHand == null) { leftHand = new IKLookAt(AvatarIKGoal.LeftHand); rightHand = new IKLookAt(AvatarIKGoal.RightHand); } UpdateIK(leftHand); UpdateIK(rightHand); }
void LerpIK(IKLookAt ik) { if (ik == null) return; if (ik.Weight < 0.8f && ik.Elapsed <= 1f && ik.Active) { //Debug.Log ("up "+ ik.Weight); ik.Weight = Mathf.Lerp(0, 0.2f, ik.Elapsed / ik.Duration); ik.FinalWeight = ik.Weight; ik.Elapsed += Time.deltaTime; } else if (ik.Weight > 0f && ik.Elapsed <= 1f && !ik.Active) { //Debug.Log ("down "+ ik.Weight); ik.Weight = Mathf.Lerp(ik.FinalWeight, 0, ik.Elapsed / ik.Duration); ik.Elapsed += Time.deltaTime; } else if (!ik.Active) { ik.Weight = 0f; } }
IEnumerator FinishPlace(Transform placeMe, float duration, IKLookAt ik, bool left = true) { yield return new WaitForSeconds(duration); ik.Elapsed = 0f; //placeMe.SetParent(ik.Target.transform); if (left) { Left.holding = null; } else { Right.holding = null; } ik.Active = false; ResumeIdling(); yield return null; }
IEnumerator FinishGrab(float duration, IKLookAt ik, bool left = true) { yield return new WaitForSeconds(duration); ResumeIdling(); ik.Elapsed = 0f; ik.Active = false; yield return null; }