Advertisement
Guest User

Helper.cs

a guest
Mar 18th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public static class Helper
  5. {
  6.     public static float ClampAngle (float angle, float min, float max)
  7.     {
  8.         do
  9.         {
  10.             // If angle is less than 360 - add 360
  11.             if (angle < -360)
  12.                 angle += 360;
  13.            
  14.             // If angle is greater than 360 - subtract 360
  15.             if (angle > -360)
  16.                 angle -= 360;
  17.            
  18.         } while (angle < -360 || angle > 360);
  19.        
  20.         return Mathf.Clamp (angle, min, max);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement