コード例 #1
0
        private void FixedUpdate()
        {
            float xAngle = joint.GetXAngle(invInitialLocalRotation);
            float num;

            for (num = xAngle - currentAngle; num < -180f; num += 360f)
            {
            }
            while (num > 180f)
            {
                num -= 360f;
            }
            currentAngle += num;
            if (num == 0f)
            {
                return;
            }
            if (currentAngle < fromAngle + 60f)
            {
                if (limitJoint == null)
                {
                    limitJoint = CreateLimitJoint(fromAngle - currentAngle, Mathf.Min(fromAngle - currentAngle + 120f, toAngle - currentAngle));
                }
            }
            else if (currentAngle > toAngle - 60f)
            {
                if (limitJoint == null)
                {
                    limitJoint = CreateLimitJoint(Mathf.Max(toAngle - currentAngle - 120f, fromAngle - currentAngle), toAngle - currentAngle);
                }
            }
            else if (limitJoint != null && currentAngle > fromAngle + 90f && currentAngle < toAngle - 90f)
            {
                Object.Destroy(limitJoint);
            }
            currentAngle = Mathf.Clamp(currentAngle, fromAngle, toAngle);
            currentValue = Mathf.InverseLerp(fromAngle, toAngle, currentAngle);
            output.SetValue((!signedOutput) ? currentValue : Mathf.Lerp(-1f, 1f, currentValue));
        }