Screen coordinates versus World coordinates

Click on the Input.mousePosition entry and check out the resulting page. The Script 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 fourth 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 ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.