Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MouseLook : MonoBehaviour {
- public float sensitivity = 700.0f;
- public float rotationX;
- public float rotationY;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- float mouseMoveValueX = Input.GetAxis("Mouse X");
- //Debug.Log("X : "+ mouseMoveValueX);
- float mouseMoveValueY = Input.GetAxis("Mouse Y");
- //Debug.Log("Y : " + mouseMoveValueY);
- rotationY += mouseMoveValueX * sensitivity * Time.deltaTime;
- rotationX += mouseMoveValueY * sensitivity * Time.deltaTime;
- //상하
- if (rotationX > 90.0f)
- rotationX = 90.0f;
- if (rotationX < -90.0f)
- rotationX = -90.0f;
- //좌우
- //if (rotationY > 90.0f)
- // rotationY = 90.0f;
- //if (rotationY < -90.0f)
- // rotationY = -90.0f;
- transform.eulerAngles = new Vector3(-rotationX, rotationY, 0.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement