Converting ui to swipe instead of tap

i currently am using a script that can be used for pc and mobile use, which is like a runner game where you tap on different points on the screen to change “Lanes” to dodge out the way and such. However it was suggested to me that it would make the movement a lot easier and better if i made it a swipe to change lanes rather than tap. Im currently using invisible ui buttons for the taps. Here is the script that controls the lanes and normal tap/key movements. If this is not possible with ui, i’m open to suggestions on what i could do to get the effect im seeking.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test : MonoBehaviour
{
    public KeyCode[] LaneInputs = new KeyCode[]
    {
            KeyCode.S,
            KeyCode.D,
            KeyCode.A
    };
    public float snapSpeed = 10f;
    public Transform[] Lanes;

    public GameObject Empty;
    public GameObject Bounce;

    private Transform targetLane;
    private Vector3 EmptyOffset = new Vector3(0, 0.2f, 0);
    private Vector3 SquashScale = new Vector3(1, 0.5f, 1);
    private Vector3 FullScale = Vector3.one;
   
        void Update()
    {
        int minSize = Mathf.Min(LaneInputs.Length, Lanes.Length);

        for (int i = 0; i < minSize; i++)
        {
            if (Input.GetKeyDown(LaneInputs[i]))
            {
                targetLane = Lanes[i];
            }
        }

   

        if (targetLane != null)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetLane.position, snapSpeed * Time.deltaTime);
        }
    }
    public void First()
    {
        int minSize = Mathf.Min(LaneInputs.Length, Lanes.Length);

        for (int i = 0; i < minSize; i++)
        {
                targetLane = Lanes[2];
        }
    }

    public void Second()
    {
        int minSize = Mathf.Min(LaneInputs.Length, Lanes.Length);

        for (int i = 0; i < minSize; i++)
        {
            targetLane = Lanes[0];
        }
    }

    public void Third()
    {
        int minSize = Mathf.Min(LaneInputs.Length, Lanes.Length);

        for (int i = 0; i < minSize; i++)
        {
            targetLane = Lanes[1];
        }
    }
}

There’s a good lesson here on picking up swipes - Architecture and Polish - Unity Learn

Although this is very helpful and is a great point, I still am in the predicament, that when i go to do the swipe, the lanes are all off. The player will change lanes however not in the direction of the swipe. Such as, if the player is in the first lane and swipes right, the player moves to the last lane, rather than moving over once, its not moving one lane at a time basically.

Without seeing the game it’s hard to advise but how about swipe from lane to lane?

Basically, the swipe starts where an invisible button is and the character moves to which button area the swipe ends on? Therefore rather than tapping a button they are swiping from one to another.

Personally though, I’ve always disliked swipe in games. I would rather tap the screen for the lane I wanted to be in as it would require less time to complete my move. I would suggest the option of tap or swipe controls as neither are too bad to implement.

Yeah there is three lanes aka three buttons and if you tap middle screen you go to the middle, if you tap left it goes to the left and so on. If i were to do swipe i would like to swipe from lane to lane but that’s where I’m having trouble figuring out how to implement it with what i have. Personally i agree with you, i prefer the tap system a lot more because i feel it’s direct and clean with the way i have it, however the person I’m developing with thinks swipe is needed lol

Well you could alter the way you do it now and adapt the controls for different methods of control.

Rather than having 3 invisible buttons, you just need to look at the screen point where the mouse/touchscreen was pressed.

In the simplest terms, you have 3 lanes so divide your screen width by 3 and have 3 sets of from x to x coordinates. If the mouse is clicked or the screen is touched within that area, that’s the lane the player wants.

With swipe, if the screen touch origin starts in an active lane (where the player is) and ends in a different lane, that’s where you move the player to.