Tag: Camera
All the articles with the tag "Camera".
Some Functions Read z as a Distance and Others Throw It Away
Code I clipped while trying to hide the cursor at the center of the screen in an FPS and raycast from that point to find where a shot lands. The original calls z a 'fix that puts the axis in camera terms'; the docs call it 'the distance of the resulting plane from the camera'. It's not a fix, it's a choice — and locking the cursor removes the need to read the value at all.
What Decides the Point to Look At Is the Plane, Not the Ray
Short code for facing the mouse, clipped while looking for how to do top-down controls. The method is right, but the plane sits at the origin and the height gets patched in separately. Put the plane at the object's position and that patch disappears.
What Decides Draw Order Is Three Things, Not Two
A learning diary I landed on while trying to find out what the Tag and Layer fields at the top of the Inspector actually do. It explains 2D draw order with Sorting Layer and Order in Layer. Both are right, but the docs call those two the higher-priority criteria and put one more underneath. And getting a layer name wrong quietly lands you in Default.
There Are Two Clamps: Swap the Arguments and Only One Throws
Mathf.Clamp takes four lines to explain. The trouble is everything outside those four lines: what happens when you swap the bounds, when NaN arrives, and when you clamp an angle.