Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MouseLook : MonoBehaviour {
  6.  
  7. public float sensitivity = 700.0f;
  8. public float rotationX;
  9. public float rotationY;
  10. // Use this for initialization
  11. void Start () {
  12.  
  13. }
  14.  
  15. // Update is called once per frame
  16. void Update () {
  17. float mouseMoveValueX = Input.GetAxis("Mouse X");
  18. //Debug.Log("X : "+ mouseMoveValueX);
  19. float mouseMoveValueY = Input.GetAxis("Mouse Y");
  20. //Debug.Log("Y : " + mouseMoveValueY);
  21. rotationY += mouseMoveValueX * sensitivity * Time.deltaTime;
  22. rotationX += mouseMoveValueY * sensitivity * Time.deltaTime;
  23.  
  24. //상하
  25. if (rotationX > 90.0f)
  26. rotationX = 90.0f;
  27. if (rotationX < -90.0f)
  28. rotationX = -90.0f;
  29. //좌우
  30. //if (rotationY > 90.0f)
  31. // rotationY = 90.0f;
  32. //if (rotationY < -90.0f)
  33. // rotationY = -90.0f;
  34.  
  35. transform.eulerAngles = new Vector3(-rotationX, rotationY, 0.0f);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement