Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraRotateScript : MonoBehaviour
- {
- // change the name above to your script name
- private float x;
- private float y;
- public float sensitivity = -1f;
- private Vector3 rotate;
- // put this script on your camera then it should work!
- // Start is called before the first frame update
- void Start()
- {
- Cursor.lockState = CursorLockMode.Locked;
- }
- // Update is called once per frame
- void Update()
- {
- y = Input.GetAxis("Mouse X");
- x = Input.GetAxis("Mouse Y");
- rotate = new Vector3(x, y * sensitivity, 0);
- transform.eulerAngles = transform.eulerAngles - rotate;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment