Exemple #1
0
        /// <summary>
        /// 角度约束(全面角度约束)
        ///【注意:组件上的欧拉角 X 轴是经过计算的,最大值为+-90度,谨慎使用】
        /// </summary>
        /// <param name="CurrentAngle">当前角度</param>
        /// <param name="Limit_Min">最小值</param>
        /// <param name="Limit_Max">最大值</param>
        /// <returns>return :约束后的角度</returns>
        public static float Constraint_Angle_Complete(float CurrentAngle, float Limit_Min, float Limit_Max)
        {
            float MinToMax = Mathf.DeltaAngle(Limit_Min, Limit_Max);       //获得+-180差值

            MinToMax = SS_EulerAngleConversion.Angle_PN_To_P360(MinToMax); //转换为360度差

            float Center = Limit_Min + MinToMax / 2;                       //中心角度

            return(Constraint_Angle_Complete_Scope(CurrentAngle, Center, MinToMax / 2));
        }
Exemple #2
0
        /// <summary>
        /// 角度约束(以0为起点的约束)
        ///【注意:组件上的欧拉角 X 轴是经过计算的,最大值为+-90度,谨慎使用】
        /// </summary>
        /// <param name="CurrentAngle">当前角度</param>
        /// <param name="Limit_Min">最小值</param>
        /// <param name="Limit_Max">最大值</param>
        /// <returns>return :约束后的角度(正负180度)</returns>
        public static float Constraint_Angle(float CurrentAngle, float Limit_Min, float Limit_Max)
        {
            CurrentAngle = SS_EulerAngleConversion.Angle_PN_To_PN180(CurrentAngle);

            return(Mathf.Clamp(CurrentAngle, Limit_Min, Limit_Max));
        }
 /// <summary>
 /// 自轴旋转
 /// </summary>
 /// <param name="CurrentAngle">当前角度</param>
 /// <param name="direction">方向值</param>
 /// <returns>return : 自转后的角度</returns>
 public static float Angle_AxisRotation(float CurrentAngle, float direction)
 {
     return(SS_EulerAngleConversion.Angle_PN_To_P360(CurrentAngle + direction));
 }