Advertisement
kadyr

Untitled

Oct 3rd, 2021
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PlayerLook : MonoBehaviour
  4. {
  5. public float mouseSense = 1f;
  6.  
  7. private void Update()
  8. {
  9. Cursor.lockState = CursorLockMode.Locked;
  10. Cursor.visible = false;
  11.  
  12. float rotX = Input.GetAxis("Mouse X") * -mouseSense;
  13. float rotY = Input.GetAxis("Mouse Y") * mouseSense;
  14.  
  15. Vector3 rotPlayer = transform.rotation.eulerAngles;
  16.  
  17. rotPlayer.x -= rotY;
  18. rotPlayer.z = 0;
  19. rotPlayer.y -= rotX;
  20.  
  21. transform.rotation = Quaternion.Euler(rotPlayer);
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement