Skip to main content
100%

Gist 19bd71e9136ab748f798122cfea72440

✓ Published0🌍 Public
Aandybak
Last edited Jun 10, 2019
Created on Jun 10, 2019

This example shows how to control a camera’s pitch and yaw using mouse input in the Unity editor, enabling a first-person-style view without a headset. The code reads raw horizontal and vertical mouse axes via `Input.GetAxisRaw("Mouse X")` and `Input.GetAxisRaw("Mouse Y")`, then applies those values to rotation speeds. Pitch is clamped between -90 and 90 degrees to prevent flipping, while yaw rotates freely. The script relies on `Quaternion.Euler` to set the local rotation and uses a `KeyCode` modifier to optionally require a held key. It is disabled outside the editor, as indicated by the `#if !UNITY_EDITOR` directive.

AI-generated description

Similar vizzes