#mouse look script error

1 messages · Page 1 of 1 (latest)

cursive fable
#

sometimes if my player looks around to fast the camera just teleports

unborn hedge
#

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

cursive fable
#

thanks <3

mossy flower
#

Hello

#

still need hellp?

cursive fable
#

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