Ejemplo n.º 1
0
    public override void UpdateIK()
    {
        if (nextNode)
        {
            float duration = (Player.transform.position - nextNode.leftHand.position).magnitude * MovementSpeed * Time.deltaTime;
            IK.MoveRoot(nextNode.transform, duration, Offset);

            if (nextMove == RIGHT)
            {
                float handDuration = (currentRight.rightHand.position - nextNode.rightHand.position).magnitude * MovementSpeed * Time.deltaTime;
                float footDuration = (currentRight.rightFoot.position - nextNode.rightFoot.position).magnitude * MovementSpeed * Time.deltaTime;

                bool done = true;
                if (!(IK.MoveRightHand(nextNode.rightHand.transform, handDuration)))
                {
                    done = false;
                }
                if (!(IK.MoveRightFoot(nextNode.rightFoot.transform, footDuration)))
                {
                    done = false;
                }
                if (done)
                {
                    currentRight = nextNode;
                    currentNode  = nextNode;
                    lastMove     = RIGHT;
                    lastIndex    = nodeIndex;
                    moving       = false;
                }
            }
            else if (nextMove == LEFT)
            {
                float handDuration = (currentLeft.leftHand.position - nextNode.leftHand.position).magnitude * MovementSpeed * Time.deltaTime;
                float footDuration = (currentLeft.leftFoot.position - nextNode.leftFoot.position).magnitude * MovementSpeed * Time.deltaTime;

                bool done = true;
                if (!(IK.MoveLeftHand(nextNode.leftHand.transform, handDuration)))
                {
                    done = false;
                }
                if (!(IK.MoveLeftFoot(nextNode.leftFoot.transform, footDuration)))
                {
                    done = false;
                }
                if (done)
                {
                    currentLeft = nextNode;
                    currentNode = nextNode;
                    lastMove    = LEFT;
                    lastIndex   = nodeIndex;
                    moving      = false;
                }
            }
        }
    }