- Home /
How to get mouse position with ray from camera???
Hi, I'm trying to get the mouse position so I can see if a rect on gui contains it... I am using Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y)
. But this is acting like it doesn't work at all. I tried debugging the Vector2, and seems like y axis is opposite? Tried -Input.mousePosition.y and doesn't work either. Any help is appreciated greaty :D :D :D
Answer by clunk47 · Aug 10, 2013 at 07:19 PM
You are close.
mousePosition = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
Not sure why you have to take the screen height then subtract mousePosition Y, kinda bass akwards lol, but this should do the trick.
as a welcome to the community, and for explaining your issue thoroughly.
If something resolves your question, please vote it up (thumbs up) and / or accept the answer (check mark).