Third person/Over the shoulder camera snapping issues. Design help

My camera system is similar to souls or remnant from the ashes where it’s at a position behind the player and slightly to the side.

Here is my camera script

    private void UpdateTransform()
    {
        _cameraTarget.position = _playerTransform.position + new Vector3(_offset.x, _offset.y, _offset.z);
        Vector3 translatedPos = Quaternion.LookRotation(_cameraTarget.forward) * new Vector3(0, _verticalRot, _offset.z) + _cameraTarget.position;
        Vector3 lookDir = _cameraTarget.position - translatedPos;
        //  Vector3 lerpedPos = Vector3.MoveTowards(_camera.transform.position, translatedPos, _followSpeed * Time.deltaTime);
        _camera.transform.position = translatedPos;
        _camera.transform.rotation = Quaternion.LookRotation(lookDir);
    }

It works as intended by default while the player is rotating to where the camera target is rotating to. The player’s forward rotation or look direction is based on where the cameraTarget is looking.

The problem comes up when this is turned off. When the player rolls, their rotation is locked while the cameraTarget or player is still able to look around. It’s when the player recovers is where the problem comes up.

When the player recovers from the dodge direction and the camera quickly snaps to where the players offset should be using transform.TransformDirection.

I understand that I can smooth out this transition but I have a feeling that I’m doing something wrong here and it’s possibly related to the position of the camera target and the use of transform.TransformDirection.

I think I found out why, the only thing the camera target should be doing is rotating and following the player. The player should be snapping to the camera targets rotation when it can. The camera should be the class that calculates the offset. My mistake was applying the offset to the camera target.

However, I ran into another issue where the camera now jitters when rotating so I cant test if the solution will work.

    private void LateUpdate()
    {
        UpdateCamera();
    }
    private void UpdateCamera()
    {
        if (_isDisabled)
        {
            return;//
        }
        _cameraTarget.transform.position = _playerTransform.position;
        //Adjust the camera target to follow the player and apply offsets
        Vector3 offSetCameraPos = _cameraTarget.transform.position + _cameraTarget.transform.TransformDirection(_offset);
        //Look at camera target while taking into account of offset;
        Vector3 finalizedCameraPos = Quaternion.LookRotation(_cameraTarget.transform.forward) * new Vector3(0, _verticalRot, _offset.z) + offSetCameraPos;
        Vector3 lookDirection = offSetCameraPos - _camera.transform.position;
        _camera.transform.position = finalizedCameraPos;
        _camera.transform.rotation = Quaternion.LookRotation(lookDirection);
    }

Seems like I was right about not applying offsets to the cameraTarget.

Rotation of player is applied in update function when not rolling.

Update camera in Update function

    private void ProcessTick()
    {
        _cameraTarget.transform.position = _playerTransform.position;
        _cameraTarget.transform.Rotate(new Vector3(0f, _horizontalRot * _playerEvents._mouseSensitivity, 0f), Space.Self); // Convert target euler
    }

Update The Camera in LateUpdate

    private void UpdateCamera()
    {
        if (_isDisabled)
        {
            return;//
        }

        Vector3 targetPos = _cameraTarget.transform.position + _cameraTarget.transform.TransformDirection(_offset.x, _offset.y, 0);
        Vector3 finalizedPos = Quaternion.LookRotation(_cameraTarget.transform.forward) * new Vector3(0, _verticalRot, _offset.z) + targetPos;
        Vector3 lookDir = targetPos - finalizedPos;

        _camera.transform.position = finalizedPos;
        _camera.transform.rotation = Quaternion.LookRotation(lookDir);
    }