Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float ClampAngle(float angle, float from, float to)
- {
- if (angle < 0f) angle = 360 + angle;
- if (angle > 180f) return Mathf.Max(angle, 360+from);
- return Mathf.Min(angle, to);
- }
- void FixedUpdate(){
- //...
- var clampRotation = can.transform.rotation.eulerAngles;
- clampRotation = Quaternion.Euler(rotation.x, rotation.y, ClampAngle(rotation.z, -45, 45))
- can.transform.rotation = clampRotation ;
- ///..
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement