Skip to content

Instantly share code, notes, and snippets.

@gkagm2
Created April 15, 2019 01:49
Show Gist options
  • Save gkagm2/daf4ecbfff997f215b9e9bd19865ff78 to your computer and use it in GitHub Desktop.
Save gkagm2/daf4ecbfff997f215b9e9bd19865ff78 to your computer and use it in GitHub Desktop.
mouseLook
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class csMouseLook : MonoBehaviour {
public float sensitivity = 500.0f;
public float rotationX;
public float rotationY;
// Update is called once per frame
void Update () {
float mouseMoveValueX = Input.GetAxis("Mouse X");
float mouseMoveValueY = Input.GetAxis("Mouse Y");
rotationX += mouseMoveValueX * sensitivity * Time.deltaTime;
rotationY += mouseMoveValueY * sensitivity * Time.deltaTime;
//마우스 앞으로 이동
if (rotationY > 45.0f)
rotationY = 45.0f;
//마우스 뒤로 이동
if (rotationY < -20.0f)
rotationY = -20.0f;
transform.eulerAngles = new Vector3(-rotationY, rotationX, 0.0f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment