- Home /
 
               Question by 
               Adnan_SMB · May 23 at 01:51 PM · 
                clamped rotation  
              
 
              How do I clamp camera rotation
I am making a mobile game and using the fixed touch field script so i want to clamp the rotation so the player cant look way down heres the script for the fixed touch field
using UnityEngine; using UnityEngine.EventSystems;
public class FixedTouchField : MonoBehaviour, IPointerDownHandler, IPointerUpHandler { [HideInInspector] public Vector2 TouchDist; [HideInInspector] public Vector2 PointerOld; [HideInInspector] protected int PointerId; [HideInInspector] public bool Pressed;
 // Use this for initialization
 void Start()
 {
 }
 // Update is called once per frame
 void Update()
 {
     if (Pressed)
     {
         if (PointerId >= 0 && PointerId < Input.touches.Length)
         {
             TouchDist = Input.touches[PointerId].position - PointerOld;
             PointerOld = Input.touches[PointerId].position;
         }
         else
         {
             TouchDist = new Vector2(Input.mousePosition.x, Input.mousePosition.y) - PointerOld;
             PointerOld = Input.mousePosition;
         }
     }
     else
     {
         TouchDist = new Vector2();
     }
 }
 public void OnPointerDown(PointerEventData eventData)
 {
     Pressed = true;
     PointerId = eventData.pointerId;
     PointerOld = eventData.position;
 }
 public void OnPointerUp(PointerEventData eventData)
 {
     Pressed = false;
 }
 
}
i want to clamp the x rotation
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                