Created
April 16, 2019 01:51
-
-
Save gkagm2/b749ea7eee47e5641cddb61e0ecd6c7d to your computer and use it in GitHub Desktop.
my MouseLook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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