Skip to content

Instantly share code, notes, and snippets.

@gkagm2
Created April 16, 2019 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkagm2/b749ea7eee47e5641cddb61e0ecd6c7d to your computer and use it in GitHub Desktop.
Save gkagm2/b749ea7eee47e5641cddb61e0ecd6c7d to your computer and use it in GitHub Desktop.
my MouseLook
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment