Controls
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
Vector2 (pitch, yaw) and applied as local Euler angles.
Input States
Camera Enabled
WhenInputEnabled = true:
- Mouse cursor is hidden and locked
- Arrow keys move the camera
- Mouse rotates the camera
Camera Disabled
WhenInputEnabled = 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
EditorControllercomponent attached to the main camera - Movement uses
transform.Translate()in local space - Rotation uses
transform.localEulerAngles - The camera maintains a
Vector3 _moveSpeedfor velocity tracking - Deceleration uses
Mathf.MoveTowardsfor smooth decay