示例#1
0
    private Vector3 GetHandTargetPosition(Vector3 posStart, Vector3 posTarget, float step)
    {
        Vector3 pos          = Vector3.Lerp(posStart, posTarget, step);
        int     insideCircle = MathFuncs.IsInsideCircle(
            pos.x, pos.y, pc.lengthForeArm,
            pc.arm_back.position.x, pc.arm_back.position.y, pc.lengthBackArm
            );

        if (insideCircle == -1 || insideCircle == 1)
        {
            float d = insideCircle == -1 ?
                      pc.lengthForeArm - pc.lengthBackArm + 0.1f
                : pc.lengthForeArm + pc.lengthBackArm - 0.1f;
            Vector3 dir = new Vector3(pos.x - pc.arm_back.position.x, pos.y - pc.arm_back.position.y, 0);
            return(dir.normalized * d + pc.arm_back.position);
        }

        return(pos);
    }