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 a method that already does that for you. Have a look at Camera.ScreenToWorldPoint .
Once you have a reference to the desired camera you can use it like this:
Vector2 touchPos = Input.touches[0].position;
Vector3 touchPosinWorldSpace = camera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, camera.nearClipPlane));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.