Skip to content Skip to sidebar Skip to footer

Unity Touch Position To World Position 2d

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

Solution 1:

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:

Vector2touchPos= Input.touches[0].position;

Vector3touchPosinWorldSpace= camera.ScreenToWorldPoint(newVector3(touchPos.x, touchPos.y, camera.nearClipPlane));

Post a Comment for "Unity Touch Position To World Position 2d"