Ceil
1 // value up, to a large value 2 Debug.Log (Mathf.ceil (0.1f/13 Debug.Log (Mathf.ceil (0.9f)); 14 Debug.Log (Mathf.ceil (-0.1f)); 05 Debug.Log (Mathf.ceil (-0.9f)); 0
Floor
1 // to take a value down to a small value 2 Debug.Log (Mathf.floor (0.1f//03 Debug.Log (Mathf.floor (0.9f) ); // 0 4 Debug.Log (Mathf.floor (-0.1f)); // -1 5 Debug.Log (Mathf.floor (-0.9f)); // -1
Round rounding
1 //Rounding2Debug.Log (Mathf.round (0.1f));//03Debug.Log (Mathf.round (0.9f));//14Debug.Log (Mathf.round (-0.1f));//05Debug.Log (Mathf.round (-0.9f));//-16 7 //If you encounter 0.5, it will be different, the result looks at the previous8 ///positive even--" -0.59 ///negative number even---"+0.5Ten ///positive number---"+0.5 One ///negative number odd--" -0.5 ADebug.Log (Mathf.round (0.5f));//1 -Debug.Log (Mathf.round (1.5f));//2 -Debug.Log (Mathf.round (-0.5f));//0 theDebug.Log (Mathf.round (-1.5f));//-2
Camp Restrictions
1 //Camp (value, Min, max)2 //limit: Limit value between min and Max, if value is less than min, return min. 3 //if value is greater than Max, return Max, return Max, or return value4Debug.Log (Mathf.clamp ( A,Ten, -));// A5Debug.Log (Mathf.clamp (5,Ten, -));//Ten6Debug.Log (Mathf.clamp ( -,Ten, -));// -7 //limit 0-1, if less than 0 returns 0, if greater than 1 returns 1, otherwise returns value8Debug.Log (MATHF.CLAMP01 (0.1f));//0.19Debug.Log (MATHF.CLAMP01 (-0.1f));//0TenDebug.Log (MATHF.CLAMP01 (2f));//1
Interpolated values
1 //interpolated Values2 //The third parameter T: Represents a percentage, 0-1, if t= 0.5f, then the return value starts from 50%3 //1. If the third parameter is a fixed value, the return value is a fixed value that varies according to the parameter size4 //2. The third parameter must be between 0-1 if <= 0, return the first parameter value, if the parameter >= 1 returns the 2nd parameter5 //Mathf.lerp (A, B, c)6 //principle return value = (b-a) *c + A;7Debug.Log (Mathf.lerp (1, -, Time.time));8Debug.Log (Mathf.lerp (1, -,0.5f));9 //Object Uniform MotionTenObj.transform.position =NewVector3 (Mathf.lerp (0, the, Time.time),0,0); One A //Mathf.lerpangle (ten, time.time); -Obj.transform.eulerAngles =NewVector3 (0, Mathf.lerpangle (Ten, -, Time.time),0);
Anti-interpolation values
Small white _unity engine _MATHF