I inserted in the main camera (I tried also in terrain , but I think it’s not this the problem) a cs that in the “Update” show me the mouse position in world coordinates.
The mouse as-is-position is perfect.
But , if I convert it with MyCamera.ScreenToWorldPoint(Input.mousePosition)
(MyCamera is the only camera I have inserted in the game) the result are the same.
it Is the same in the meaning the coordinates returned to the log is every the same numnbers. Change just if I move the camera (and however with impossible numbers).
What’s wrong?
I need the world coordinates!
Help!(Please)
ScreenToWorldPoint return me everytime the camera position, not the transformed coordinates of the parameter…the nightmare increase…
Can you post the code you are using for this? It’s as well to check it out before logging a bug.
Vector3 V=MyCamera.ScreenToWorldPoint(Input.mousePosition);
Debug.Log(V);
that’s all…
is included in the onmouseover of the terrain and that’s running, because I see the log just when I move the mouse over the terrain.
If I do
Debug.Log(Input.mousePosition);
I can see the value that changes correctly.
PS “MyCamera” is the main and only camera , and it’s not null.
Approxlimatly I found the “error”.
I have to set the z of the vector I passed to the ScreenToWorldPoint at MyCamera.pixelHeight…now the cube I move is connected to the mouse…but if I have to use another parameter of camera please tell me!
Also better : to see the point you “touch” the plane terrain with the mouse you can use
http://answers.unity3d.com/questions/3152/using-a-mouse-grab-an-object-and-spin-it-in-3d