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.