public void Update()
 {
     switch (state)
     {
         case PrayingIKState.INACTIVE:
             break;
         case PrayingIKState.STARTING:
             currAnimTime += Time.deltaTime;
             float weight;
             if (currAnimTime > maxTime)
             {
                 currAnimTime = maxTime;
                 weight = 1;
                 state = PrayingIKState.PRAYING;
             }
             else
             {
                 float normTime = currAnimTime / maxTime;
                 weight = Mathf.Sin(normTime * Mathf.PI / 2);
             }
             ikSecondary.solver.leftHandEffector.positionWeight = weight;
             ikSecondary.solver.rightHandEffector.positionWeight = weight;
             break;
         case PrayingIKState.PRAYING:
             break;
         case PrayingIKState.RETRACTING:
             currAnimTime -= Time.deltaTime;
             if (currAnimTime < 0)
             {
                 currAnimTime = 0;
                 weight = 0;
                 state = PrayingIKState.INACTIVE;
             }
             else
             {
                 float normTime = currAnimTime / maxTime;
                 weight = Mathf.Sin(normTime * Mathf.PI / 2);
             }
             ikSecondary.solver.leftHandEffector.positionWeight = weight;
             ikSecondary.solver.rightHandEffector.positionWeight = weight;
             break;
     }
 }
        public void EndPrayer(Transform egg)
        {
            if (state != PrayingIKState.INACTIVE)
            {
                ObjectController oc = egg.parent.GetComponent<ObjectController>();
                if (oc) oc.EndPrayer();

                state = PrayingIKState.RETRACTING;
            }
        }
        public void StartPrayer(Transform character, Transform egg)
        {
            if (state == PrayingIKState.INACTIVE)
            {
                ObjectController oc = egg.parent.GetComponent<ObjectController>();
                if (oc) oc.StartPrayer();

                state = PrayingIKState.STARTING;
                Quaternion rotation = Quaternion.LookRotation(egg.position - character.position);
                Vector3 target = egg.position - (rotation * new Vector3(0, 0, 1.5f));
                ikSecondary.solver.leftHandEffector.position = target;
                ikSecondary.solver.rightHandEffector.position = target;
            }
        }
 public PrayingIKController(CrossfadeFBBIK[] iks)
 {
     ikSecondary = iks[1];
     state = PrayingIKState.INACTIVE;
     maxTime = 0.4f;
 }