'How to improve unity management on android? unity2D

please tell me how to make the player control was not tied to the finger, but for example to drive in any part of the screen and the player will move from the point where he stopped? details in comments


    using UnityEngine;

    public class playerMove : MonoBehaviour
    {
    public Transform player;
    
       void OnMouseDrag()
        {
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            mousePos.x = mousePos.x < -2.1f ? -2.1f : mousePos.x;
            mousePos.x = mousePos.x > 2.1f ? 2.1f : mousePos.x;
            mousePos.y = mousePos.y > 4.5f ? 4.5f : mousePos.y;
            mousePos.y = mousePos.y < -4.5f ? -4.5f : mousePos.y;

            player.position = new Vector2(mousePos.x, mousePos.y);
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source