Need Help in understanding ScreenToWorldPoint
Hi,
I am new to Unity. I am working on a space shooter tutorial and i want to move the player object with in the bounds of the phone screen. After a lot of googling i found below code and it is working as expected.
Vector3 minScreenBounds = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)); Vector3 maxScreenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
I have tested this in my android device and it is working great. I was wondering how the ScreenToWorldPoint method is returning exact bounds of my phone. I have seen its documentation and i could not understand it. I would be thankful if anybody explains it.
Thanks In Advance.
Screen.width
& Screen.height
contain the dimensions - what's not to understand?
In the first statement we are taking the co-ordinates (0,0,0). When i added logs, the logs shown negative values for x,z. and the second statement is having screen.width and height. it gave positive values. I was wondering how the (0,0,0) co-ordinates gave the lower bounds of the screen.
in any square the four corners are (0,0),(0,width),(0,height) and (width,height).
Your answer
Follow this Question
Related Questions
Changing resolution affect camera width but not height 0 Answers
Camera problems 0 Answers
Vertical resolution of Kinect-v2 in Unity 3D 0 Answers
How can I set a standard camera resolution size for my 2D game [Beginner] 0 Answers
Pixel Perfect Camera help 0 Answers