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 fourth grade.
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 3.x Game Development by Example 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.