c# – How to move 3D Object With Touch Dragging Finger By the screen In android Unity Game


My Code is As Followed:-using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Sphere : MonoBehaviour

{
(SerializeField)
private Touch touch;
private float speedModifier;
// Start is called before the first frame update
void Start()
{
speedModifier = 0.01f;
}

// Update is called once per frame
void Update()

{
    if (Input.touchCount > 0)
    {
        touch = Input.GetTouch(0);

        if (touch.phase == TouchPhase.Moved)
        {
            transform.position = new Vector3(
                transform.position.x + touch.deltaPosition.x * speedModifier,
                transform.position.y,
                transform.position.z + touch.deltaPosition.y * speedModifier);
        }
    }

}

}
I tried with this code but object isnot even responding