MouseLookAround.cs
using UnityEngine; public class MouseLookAround : MonoBehaviour { float rotationX = 0f; float rotationY = 0f; public float sensitivity = 15f; void Update() { rotationY += Input.GetAxis("Mouse X") * sensitivity; rotationX += Input.GetAxis("Mouse Y") * -1 * sensitivity; transform.localEulerAngles = new Vector3(rotationX,rotationY,0); } }
Improved Script(Smooth Rotation & Sensitivity Axis Control)
using UnityEngine; public class MouseLookAround : MonoBehaviour { float rotationX = 0f; float rotationY = 0f; public Vector2 sensitivity = Vector2.one * 360f; void Update() { rotationY += Input.GetAxis("Mouse X") * Time.deltaTime * sensitivity.x; rotationX += Input.GetAxis("Mouse Y") * Time.deltaTime * -1 * sensitivity.y; transform.localEulerAngles = new Vector3(rotationX, rotationY, 0); } }