using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float sensitivity = 100f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
//getting the inputs
float mouseX = Input.GetAxis("Mouse X");
float mouseY = Input.GetAxis("Mouse Y");
float movementY = -mouseY * sensitivity * Time.deltaTime;
float movementX = mouseX * sensitivity * Time.deltaTime;
//actually rotating the object
Vector3 rotation = new Vector3(movementY, movementX, 0);
float clampedrotationX = rotation.x;
clampedrotationX = Mathf.Clamp(clampedrotationX, -90, 90);
rotation = new Vector3(clampedrotationX, movementX, 0);
transform.Rotate(rotation);
}
}
This is my camera code, i think it should work but the camera is doing weird stuff.