#mouse look script error
1 messages · Page 1 of 1 (latest)
don't multiply mouse input by deltaTime, it's already a delta from the previous frame so it doesn't need to be multiplied by that. Also it's three ` not ' for posting code
after you remove the deltaTime multiplication make sure to change the mouse sensitivity in both the script and the inspector
thanks <3
actually yes
i still get the same bug
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 0f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
``` here's the mouse look script now