Drag to Rotate/Scroll a Camera

I’m trying to setup a rotating/scrolling camera (position is locked) where the movement matches a finger drag (like PULLING the scene into focus).

Everything appears to work, except that I’m finding that when the drag starts the camera will always initially snap back before performing the proper drag/scroll action.

I presume this isn’t functioning correctly due to the Slerp argument (or maybe even the ScreenWorldToPoint) , but I’m not quite certain how to resolve it. Any thoughts or suggestions (or even a better method) would be appreciative.

here is my code…Thank you.

public float damping = 5f; 
private Vector3 targetPosition; // screen coordinate of touch (x,y) converted to world via 'camera.ScreenToWorldPoint(fingerPosition.x, fingerPosition.y, camera.nearClipPlane)'
// this value is automatically updated as long as the user is dragging 

void Update()
{
    Quaternion rotation = Quaternion.Inverse(Quaternion.LookRotation(targetPos - transform.position)); 
    tranform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping); 
    transform.forward = new Vector3(transform.forward.x, 0, transform.forward.z); // limit rotation along Y
}

i dont know if this what you want, or does this work, but heres my idea.there is a “mouse look” script in:

Standard\Assets\Character Controllers\Sources\Scripts
u can change that code to only work when the mouse button is down, and then use that script on the camera u want.

i think that this is what u want.

copy paste this to mouse look:

// C#
// MouseLook.cs
using UnityEngine;
using System.Collections;

[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour
{
    public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
    public RotationAxes axes = RotationAxes.MouseXAndY;
    public float sensitivityX = 15F;
    public float sensitivityY = 15F;
    
    public float minimumX = -360F;
    public float maximumX = 360F;
    
    public float minimumY = -60F;
    public float maximumY = 60F;
    public float h = -180;
    
    float rotationY = 0F;
    
    void Update ()
    {
        if(Input.GetMouseButton(0))
        {
            if (axes == RotationAxes.MouseXAndY)
            {
                float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
                transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
                transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
            }
        }
    }
    
    void Start ()
    {
        transform.Rotate(h,0,0);
        // Make the rigid body not change rotation
        if (rigidbody)
            rigidbody.freezeRotation = true;
    }
}

EDIT:negetive the X and Y to get the drag like.