moving like a snake to the right and to the left

using UnityEngine;

public class test : MonoBehaviour
{
   [SerializeField]
    private float speed = 10f;


    
    public void Update()
    {
        transform.Translate(Vector3.up *speed * Time.deltaTime, Space.World);
    }
}

have a ridiculously simple script, but i donk know how to forse him to moving to the right or to the left with my finger, on my phone, i dont need buttons UI or others. i just want , its being like with joystick, but only to the left and to the right direction, and try to swipe or random position on the mobile screen, and smoothly moving… PLS HELP ! i google it already about a week!!! it becomes me crazy

Could you maybe make invisible buttons that you could still press but they cant be seen?