How can I transform the touch position (On phones) to world position.
For instance if my phone’s screen size is 1440 by 2560 and my touch position on the phone is X 600 Y 700. How can I transform that position to world position on unity?
I need that so I can know where the user put his finger.
There is no true 2D position. Even when using 2D features, positions are still 3D. For 2D, Orthographic camera, with rotation (0,0,0) you can do:
var pos = Camera.main.ScreenToWorldPoint(touchposition);
pos.z = transform.position.z;
This will be the finger position at the ‘z’ position of the object with the script.
Vector3 screenPos = new Vector3(Input.mousePosition, Input.mousePosition, 10);
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
worldpos will be a world point where you touched, 10 meters from the camera.