help with rotation, mouse input and time.deltatime, a thirdperson script

hello unity forums, I haven’t used unity 3d in a long while… and I thought I would pick it up again and do something interesting. I have gotten back into coding in C# but I am not getting the desired behavior from a script that I wrote. (sorry for the first paragraph of code non-formatted, it shows up wrong in the preview)

using System;
using UnityEngine;

public class playerlooky : MonoBehaviour
 {
    public float mouseSensitivity = 100.0f;
    public float clampAnglePos = 80.0f;
    public float clampAngleNeg = 50.0f;
    public bool mode = true;
    public bool Switch = false;
    public float MouseMagnitude = 2f;
    private Vector3 tmpMousePosition;
    private Vector2 MousePos2D;
    private Vector2 CurrentMousePos;
    public float timeleft = 0;
    public float CurrentMagnitude = 0;

    private float rotY = 0.0f; // rotation around the up/y axis
    private float rotX = 0.0f; // rotation around the right/x axis

    void Start()
    {
        Vector3 rot = transform.localRotation.eulerAngles;
        rotY = rot.y;
        rotX = rot.x;
        tmpMousePosition = Input.mousePosition;
        MousePos2D.x = tmpMousePosition.x;
        MousePos2D.y = tmpMousePosition.y;
    }

    void Update()
    {
        CurrentMousePos.x = Input.mousePosition.x;
        CurrentMousePos.y = Input.mousePosition.y;
        CurrentMagnitude = Mathf.Sqrt(Mathf.Pow(CurrentMousePos.x, 2) + Mathf.Pow(CurrentMousePos.y, 2));

        if (mode == true)
        {
            float mouseY = -Input.GetAxis("Mouse Y");
            float mouseX = Input.GetAxis("Mouse X");

            rotY += mouseY * mouseSensitivity * Time.deltaTime;
            rotX += mouseX * mouseSensitivity * Time.deltaTime;

            rotY = Mathf.Clamp(rotY, -clampAngleNeg, clampAnglePos);

            Quaternion localRotation = Quaternion.Euler(rotY, rotX, 0.0f);
            transform.rotation = localRotation;
        }

        if (CurrentMagnitude > MouseMagnitude)
        {
            timeleft = 0;
        }

        if (Switch == false)
        {
            timeleft += Time.deltaTime;
            mode = true;
        }

        if (transform.eulerAngles.x == 0 & transform.eulerAngles.y == 0 & Switch == true)
        {
            Switch = false;
            mode = true;
        }

        if (timeleft < 10)
        {
            Switch = true;
            mode = false;
            timeleft = 0;
        }

        if (Switch == false)
        {
            transform.rotation = Quaternion.Euler(Mathf.Lerp(transform.eulerAngles.x, 0, timeleft), Mathf.Lerp(transform.eulerAngles.y, 0, timeleft), 0);
            timeleft += 0.5f * Time.deltaTime;
        }
        
    }
}

what it is supposed to do is set up variables for keeping track of mouse position and attached object rotation then determine the amount the user has moved the mouse from the last position. the next “mode” block is for one of the modes it operates in, it has two states, one where the object is controlled by the user, the other is when the user hasn’t moved the mouse enough by a set amount and rotates the object back to its default rotation relative to its parent.
instead of giving the user control I have run into a recurring problem in that If I have more than 1 transform of any type be it quaternion, rotation or euler, none of the rotations will come into effect and leave the object stranded in its default rotation relative to the camera.
I hope I have provided enough information and will check back when I can, thanks!

First set Cursor.lockState to locked so cursor is always in middle of screen. Then use Input.GetAxis(“Mouse X”) and “Mouse Y” to get a delta of mouse movement, and then just do if Input.GetAxis(“Mouse X”) > 1 or other number to check if mouse moved more than that