Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class csMouseLook : MonoBehaviour {
  6.  
  7. public float sensitivity = 500.0f;
  8. public float rotationX;
  9. public float rotationY;
  10.  
  11.  
  12.  
  13. // Update is called once per frame
  14. void Update () {
  15. float mouseMoveValueX = Input.GetAxis("Mouse X");
  16. float mouseMoveValueY = Input.GetAxis("Mouse Y");
  17.  
  18. rotationX += mouseMoveValueX * sensitivity * Time.deltaTime;
  19. rotationY += mouseMoveValueY * sensitivity * Time.deltaTime;
  20.  
  21.  
  22. //마우스 앞으로 이동
  23. if (rotationY > 45.0f)
  24. rotationY = 45.0f;
  25. //마우스 뒤로 이동
  26. if (rotationY < -20.0f)
  27. rotationY = -20.0f;
  28. transform.eulerAngles = new Vector3(-rotationY, rotationX, 0.0f);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement