Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MouseLook : MonoBehaviour {
- // Speed of the rotation are public to set in Unitys editor
- public float speedH = 5.0f;
- public float speedV = 5.0f;
- //
- private float rotationX = 0.0f;
- private float rotationY = 0.0f;
- // Flip the movement of the mouse in Y or not
- public bool flipY = true;
- // Use this for initialization
- void Start () { }
- // This is called in every frame
- void Update()
- {
- rotationX += speedH * Input.GetAxis("Mouse X");
- rotationY -= speedV * Input.GetAxis("Mouse Y") * (flipY ? -1 : 1);
- transform.eulerAngles = new Vector3(rotationY, rotationX, 0.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement