Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. float ClampAngle(float angle, float from, float to)
  2.  {
  3.  
  4.      if (angle < 0f) angle = 360 + angle;
  5.      if (angle > 180f) return Mathf.Max(angle, 360+from);
  6.      return Mathf.Min(angle, to);
  7.  }
  8.  
  9.  
  10. void FixedUpdate(){
  11.     //...
  12.     var clampRotation = can.transform.rotation.eulerAngles;
  13.  
  14.     clampRotation = Quaternion.Euler(rotation.x, rotation.y, ClampAngle(rotation.z, -45, 45))
  15.     can.transform.rotation = clampRotation ;
  16.     ///..
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement