Limit Cam rotation
I want to know how to limit the rotations of my camera
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Camera : MonoBehaviour {
 public GameObject target;
 public float rotateSpeed = 5;
 Vector3 offset;
 void Start() {
     offset = target.transform.position - transform.position;
 }
 void LateUpdate() {
     float horizontal = Input.GetAxis("Mouse X") * rotateSpeed;
     target.transform.Rotate(0, horizontal, 0);
     float vertical = Input.GetAxis("Mouse Z") * rotateSpeed;
     target.transform.Rotate(0, 0, vertical);
     float desiredAngle = target.transform.eulerAngles.y;
     Quaternion rotation = Quaternion.Euler(0, desiredAngle, 0);
     transform.position = target.transform.position - (rotation * offset);
     transform.LookAt(target.transform);
 }
 
               I've been reaching a lot but i cant find anything that i could understand since im very new at scripting
               Comment
              
 
               
              Your answer