I’ve been searching all day, but nothing seems to work. As the title says I want to be able to drag a 2D sprite with touch input. i tried a lot of stuff so one code example wouldn’t make sense, but I just want the transform.position of the 2D object changed to where the finger touches the screen.
You’ll want to use Unity - Scripting API: Touch.position ,
like this:
if (Input.touchCount > 0) {
Touch touch = Input.GetTouch(0);
sprite.position = touch.position;
}
Touch is where the play is currently touching the screen, it gives you a full vector that you can make the sprite follow in the Update() method.
Hope this helps!