O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Screen Coordinates versus World Coordinates

Click on the Input.mousePosition entry and check out the resulting page. The Language Reference tells us that we have a new origin to deal with. Unity treats our screen like a flat, 2D plane, with (0, 0) the origin in the bottom-left corner of the screen like a bar graph from 4th grade.

Screen Coordinates versus World Coordinates

We have a code example here, but it looks a little hairy. What's a Physics.Raycast? I have no idea. And how do we get the x, y, and z values for Input.mousePosition?

The answer is a tiny bit sneaky. Look at the top of the screen where it tells us that Input.mousePosition is a Vector3. What's a Vector3? I dunno. Click on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required