Why does Camera.main.ScreenToWorldPoint return only to the nearest tenths?

Whenever I try to convert my mouse coordinate

Input.mousePosition

into World Coordinates using

Camera.main.ScreenToWorldPoint(mousePos);

It returns the World Position to the nearest tenths, such as 1.1, 1.2, 1.3, 1.4.

However, all my units are in 100 Units per Pixel.

This is horrible. I need it to tell me the World Coordinates to the hundredths. 1.10, 1.11, 1.12, 1.13.

What am I doing wrong?

Vector3 mousePOS = Input.mousePosition;
Vector3 camera2worldPOS = Camera.main.ScreenToWorldPoint(mousePOS);
Debug.Log ("Camera to World Position : " + camera2worldPOS);
1 Like

If you use the vector you’re getting, you’ll find that it contains the correct, detailed value. Vector3’s default .ToString() function (which is implicitly used when you Debug.Log it) is where it’s rounding to the nearest 0.1, not the vector itself. If you change your last line to this, you’ll see it contains the real values:

Debug.Log ("Camera to World Position : (" + camera2worldPOS.x + ", " + camera2worldPOS.y + ", "+camera2worldPOS.z+")");
1 Like

thx

1608094--97543--$bc754f52a0f36317ddabfb626f84d559f1406eee36e63f0811a0233f3cd505e7.jpg

1 Like