Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerLook : MonoBehaviour
- {
- public float mouseSense = -1f;
- private void Update()
- {
- Cursor.lockState = CursorLockMode.Locked;
- Cursor.visible = false;
- float rotX = Input.GetAxis("Mouse X") * mouseSense;
- float rotY = Input.GetAxis("Mouse Y") * mouseSense;
- Vector3 rotPlayer = transform.rotation.eulerAngles;
- rotPlayer.x -= rotY;
- rotPlayer.z = 0;
- rotPlayer.y -= rotX;
- transform.rotation = Quaternion.Euler(rotPlayer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement