void Update() { //Get mouse input float mouseX = Input.GetAxis("Mouse X"); //float mouseY = Input.GetAxis("Mouse Y"); //Get current rotation Vector3 tempEulerAngle = transform.localEulerAngles; //Change left right rotation tempEulerAngle.y += mouseX * _rotationSpeed * Time.deltaTime; //Change up down rotation //tempEulerAngle.x += mouseY * _rotationSpeed * Time.deltaTime; //This needed to be done on another gameObject child otherwise //when we look down we move (because we are a capsule). //Rotate transform.localEulerAngles = tempEulerAngle; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter