> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rollingquest.kramgames.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Editor Camera

> How the editor camera works in RollingQuest: movement, rotation, acceleration, sensitivity, and input handling.

The editor camera provides free-flight navigation through the 3D viewport. It uses an acceleration-based movement model with mouse-driven rotation.

## Controls

| Input          | Action                                    |
| -------------- | ----------------------------------------- |
| **Arrow Keys** | Move forward, backward, strafe left/right |
| **Mouse**      | Rotate camera (look around)               |

## Movement Model

The camera uses a physics-inspired movement system:

### Acceleration

When an arrow key is held, acceleration is applied in the corresponding direction. The acceleration magnitude is controlled by `_accelerationMod`.

### Velocity

Velocity accumulates each frame based on acceleration. It is clamped to `_maximumMovementSpeed` to prevent extreme movement.

### Deceleration

When no acceleration is applied (key released), velocity decays toward zero using `_decelerationMod`. This creates smooth stopping behavior.

## Rotation

Mouse movement rotates the camera:

* **Horizontal mouse movement** rotates around the world Y axis (yaw)
* **Vertical mouse movement** adjusts the local pitch
* Pitch is clamped to `_maxXAngle` (default: 80°) to prevent flipping

The rotation is stored as a `Vector2` (pitch, yaw) and applied as local Euler angles.

## Input States

### Camera Enabled

When `InputEnabled = true`:

* Mouse cursor is hidden and locked
* Arrow keys move the camera
* Mouse rotates the camera

### Camera Disabled

When `InputEnabled = false`:

* Mouse cursor is visible and unlocked
* Arrow keys have no effect
* Mouse movement has no effect
* Used when menus are open

## Position and Rotation Persistence

The camera's position and rotation are saved between sessions:

* Stored in `EditorPersistentState.CameraPosition`
* Stored in `EditorPersistentState.CameraRotation`
* Restored when the editor loads

## Technical Details

* The camera is an `EditorController` component attached to the main camera
* Movement uses `transform.Translate()` in local space
* Rotation uses `transform.localEulerAngles`
* The camera maintains a `Vector3 _moveSpeed` for velocity tracking
* Deceleration uses `Mathf.MoveTowards` for smooth decay
