- Home /
ScreenToWorldPoint not working properly on deployment
I am trying to make a ship move to a touch point. I get the Vector2 position of the touch, then convert it to world coordinates and then move the ship to that position. It is working properly on the Unity editor, however if i deploy it to a Windows Phone 8.1 (Lumia 1520) The screen coordinates are reduced: These are the coordinates on the PC with the respective value that Im getting on the phone:
Bottom Left Corner -> PC: (0,0) Phone (0, 639) which is like 1/3 of the screen up from the corner Bottom Right Corner ->PC: (525, 0)Phone (720, 639).
Camera is Orthographic, Native and Preview Resolution are 1080x1920
And here is the code to process the touch point: void OnMultiTap(Tap tap){ Vector3 tapPos = Camera.main.ScreenToWorldPoint(new Vector3(tap.pos.x,tap.pos.y, -1000)); tapPos.z = 0; iTween.MoveTo(gameObject, iTween.Hash("position", tapPos, "time", 1 ); Debug.Log (Screen.width + " h: " + Screen.height); Debug.Log (tap.pos + " v3 " + tapPos); }
My camera is -1000 units in the back, thats why I set that Z value, then change it to 0 for the ship only to move in 2 dimensions.
Any help is appreciated! Thanks!
I don't understand your -1000. For ScreenToWorldPoint(), the 'z' value should always be the positive distance in front of the camera for a perspective camera.
$$anonymous$$y Camera is placed on (0,0,-1000) and its orthographic, do you think that if i move it to (0,0,1000) and set the ScreenToWorldPoint Z value positive will fix it?
Are you by any chance using Unity Remote for testing? I have experienced issues with touch being dislocated when using Unity Remote.
Nope, im just exporting a Solution file for windows phone 8, then upgraded it through visual studio to 8.1
Could you pleas post the code, for the way you access your touch coordinates?
Your answer
Follow this Question
Related Questions
Keep Aspect ratio/Letterbox and maintain pixel perfection 0 Answers
First Person Camera Pixelation 1 Answer
Camera horizontal distortion? 1 Answer
Build camera problems... 0 Answers