I need help finding whats wrong

I was taking this tutorial ( https://www.youtube.com/watch?v=JzZjPsVbibI&list=PLp9qc2uVlKaeLeEh5RQKHaY3R_MZyQJ6j ) and I was on the part where the mouse changes the cameras angle, I finished it, and it won’t stop spinning towards the right, Im pretty new to c# so I cant really tell whats wrong, but heres what I had in the script:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEngine;

public class MouseLook : MonoBehaviour
{
    public float sensitivity = 1.5f;
    public float smoothing = 1.5f;


    private float xMousePos;
    private float smoothedMousepos;

    private float currentLookingpos;

    private void Start()
    {
        //lock and hide cursor
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }


    void Update()
    {
        GetInput();
        ModifyInput();
        MovePlayer();
    }

    void GetInput()
    {
        xMousePos = Input.GetAxisRaw("Mouse X");
    }

    void ModifyInput()
    {
        xMousePos += sensitivity + smoothing;
        smoothedMousepos = Mathf.Lerp(a: smoothedMousepos, b: xMousePos, t: 1f / smoothing);
    }
   
    void MovePlayer()
    {
        currentLookingpos += smoothedMousepos;
        transform.localRotation = Quaternion.AngleAxis(currentLookingpos, transform.up);
    }
       

}

If you can find it please help.

I believe you copied that incorrectly from the tutorial. Sensitivity and smoothing are factors and thus should be multiplied, not added.

2 Likes

Im not sure if it works yet because im buay right now but thanks!