Question by
Mufas · Mar 22, 2020 at 01:55 PM ·
positionviewportcamera.main
Problems using Camera.main.ScreenToViewportPoint(Input.mousePosition) as it gives the wrong position
I'm trying to find the mouse's position on the viewport, so I can use it in a shader. I'm trying to use:
Camera.main.ScreenToViewportPoint(Input.mousePosition)
But this grants me the wrong position. When I'm holding my mouse at the center of the gamewindow, it gives me the position (0.7, 0.6) but it should be (0.5, 0.5).
But when I hold the mouse in the bottom left corner, it gives me (0.0, 0.0) which is correct.
When I hold the mouse in the upper right corner, it gives me (1.3, 1.2) which is wrong as it should be (1.0, 1.0).
It's as if the position is offset, or something, or it thinks the window is smaller than it is. I don't know what is wrong :(
Comment