Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MouseLookPivot : MonoBehaviour {
- public float turnSpeed = 1;
- public float tiltRange = 45;
- float lookAngle = 0;
- float tiltAngle = 0;
- // Update is called once per frame
- void Update () {
- float x = Input.GetAxis("Mouse X");
- float y = Input.GetAxis("Mouse Y");
- lookAngle += x*turnSpeed;
- tiltAngle += y*turnSpeed;
- tiltAngle = Mathf.Clamp (tiltAngle, -tiltRange, tiltRange);
- transform.rotation = Quaternion.Euler( tiltAngle, lookAngle, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment