How can I check mouse position in world coordinates?

Hi

Im still new to unity3d and I’m discovering that there are different coordinate systems.

  • GUI screen coordinate: 0,0 top left

  • Screen coordinate: 0,0 bottom left

  • Viewport space: normalized and relative to the camera 0,0 bottom
    left 1,1 top right

    World Space: what transform.position uses

I have some prefabs rendering in the scene and I want to check if the mouse cursor is
less than -.32f from the prefabs left side or +.32f from the prefabs right side.

If i could somehow check the mouse position.x against the prefabs transform.position.x i could accomplish this, but I don’t know how to get mouse coordinates in world space or if it’s even possible. If it’s not possible what would be the way to accomplish something like this?

Thanks!

Go to the raycast page and use one of the examples:

they all do what you ask for with more or less info