Camera System
Overview
The Camera system provides both a runtime ECS camera component and an editor fly/orbit camera. During edit mode, the editor camera controls the viewport. During play mode, the engine switches to the entity camera marked as the main camera.
Editor Camera
The editor viewport has a built-in camera with the following controls:
Adding a Camera Component
To define a runtime camera for your game:
- Select an entity in the Scene Hierarchy (or create a new one)
- In the Inspector, click Add Component > Camera
- Configure the camera properties
- Check isMain to make it the active play-mode camera
Camera Properties
Runtime Camera System
When you press Play, the engine activates a CameraSystem that:
- Queries all entities with both
CameraandTransformcomponents - Finds the entity with
isMain == true - Computes view and projection matrices from that entity's Transform and Camera properties
- Feeds those matrices to the renderer
When you press Stop, the editor camera resumes control.
If no camera has isMain == true, the viewport will show a default view during play mode. Always mark one camera as main.
Multiple Cameras
You can have multiple camera entities in a scene. Only one should have isMain = true at a time. Switch between them in code using engine.SetMainCamera():
For detailed scripting examples, see Camera Scripting.
Frustum Gizmo
In edit mode, every camera entity displays a wireframe frustum in the viewport showing:
- Near and far clipping planes
- Field of view cone (or orthographic box)
- Forward direction indicator (blue line)
- Up direction triangle at the top
This helps you position and orient cameras in the scene without entering play mode.
Inspector Preview
When you select a camera entity in the editor, the Inspector panel shows a live preview thumbnail at the top of the Camera component. This renders the scene from the camera's perspective in real-time, updating as you adjust the Transform or camera properties.
Integration Notes
- The editor viewport uses its own
EditorCamera, completely separate from any Camera components - During play mode, the
CameraSystemruns atPreUpdatephase, setting view/projection before the render pass - Camera components support both Perspective and Orthographic projection
- The gizmo and preview are only visible in edit mode
- Gizmo manipulation (translate/rotate/scale) is disabled during play mode