i followed a brackeys tutorial on a mouselook script but it was stuck looking at the floor, this is my script:
public Transform playerBody;
float xRotation = 90f;
// 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 * Time.deltaTime;
float mouseY = Input.GetAxis(“Mouse Y”) * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, 90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 90f, 90f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
anybody got a fix?
Why are you putting 90f here?
Quaternion.Euler(xRotation, 90f, 90f);Shouldn’t it just be:
Quaternion.Euler(xRotation, 0f, 0f);
Also:
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
you should not use deltaTime for these calculations.
Read what it says here about mouse axis: Unity - Scripting API: Input.GetAxis
w
so i just change it to “0f” and “time.;” ?
dude what do i put in place of delta time? and i changed them all to 0f and it’s still stuck to the ground