Aego Русский

Virtual cameras

Each frame the brain picks one virtual camera per output:

  1. The enabled virtual camera with the highest Priority. Equal priorities pick the camera created first.
  2. A Camera Zone 2D with the target inside lifts its camera to the zone's priority. On a tie the zone beats an ordinary camera, and the zone entered later beats an earlier one.
  3. camera.BlendTo and camera.Cut override everything until camera.Release.

The pose comes from the virtual camera's node: its interpolated position and rotation, and Zoom, where 0 keeps the zoom of the Camera 2D. A Camera Follow 2D on the same node replaces the position. The node's transform is never changed; the camera only moves the view.

In Try it, the Director script raises Close, then Tilt, for two seconds each, and the view blends to them and back. Change Zoom, Blend Time or Blend Curve of Close in the Inspector and watch the next blend; the script is under the scene.

On this page

Blends

When another camera becomes active, the view blends from the pose it shows now to the new camera over its Blend Time, shaped by Blend Curve. A switch during a blend starts from the current view, never from the old camera. Zoom blends evenly on screen. Blend Time 0 cuts.

Bounds

Use Bounds keeps the visible area inside Bounds, a world rectangle. When the area is smaller than the view on an axis, the view is centred on it there.

Try it

Change the example parameters and compare the result. Reset restores the initial scene.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene10 nodes
Close
Transform
position[-6, 0]rotation0scale[1, 1]
Virtual Camera 2D
priorityint-1outputstring""zoomfloat110blendTimefloat1blendCurveCurve{ ease=inOutQuad }timeDomainenumunscaleduseBoundsboolfalseboundsRect[0, 0, 0, 0]snapToPixelsboolfalse
Tilt
Transform
position[6, -0.4]rotation0.14scale[1, 1]
Virtual Camera 2D
priorityint-1outputstring""zoomfloat80blendTimefloat1.5blendCurveCurve{ ease=outBack }timeDomainenumunscaleduseBoundsboolfalseboundsRect[0, 0, 0, 0]snapToPixelsboolfalse
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Virtual Camera 2D
priorityint0outputstring""zoomfloat0blendTimefloat1blendCurveCurve{ ease=inOutQuad }timeDomainenumunscaleduseBoundsboolfalseboundsRect[0, 0, 0, 0]snapToPixelsboolfalse
Camera 2D
zoomfloat40viewportRect[0, 0, 1, 1]maskint-1orderint0clearbooltrueclearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
A
Transform
position[-6, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#ef4444fforiginVec2[0.5, 0.5]sizeVec2[1.6, 1.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
B
Transform
position[-3, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#f59e0bfforiginVec2[0.5, 0.5]sizeVec2[1.6, 1.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
C
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#22c55efforiginVec2[0.5, 0.5]sizeVec2[1.6, 1.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
D
Transform
position[3, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#3b82f6fforiginVec2[0.5, 0.5]sizeVec2[1.6, 1.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
E
Transform
position[6, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#a855f7fforiginVec2[0.5, 0.5]sizeVec2[1.6, 1.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Floor
Transform
position[0, 1.6]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#374151fforiginVec2[0.5, 0.5]sizeVec2[18, 0.4]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Director
Transform
position[0, 0]rotation0scale[1, 1]
Scriptmain.aes
package demo

// Director raises Close, then Tilt, for Hold seconds each; the view blends between them.
script Director {
    @export var Close ComponentRef<VirtualCamera2D>
    @export var Tilt ComponentRef<VirtualCamera2D>
    @export var Hold float = 2

    var t float
    var shot int

    func Update(dt float) {
        t += dt
        if t < Hold {
            return
        }
        t = 0
        shot = (shot + 1) % 4
        Close.Priority = -1
        Tilt.Priority = -1
        if shot == 1 {
            Close.Priority = 1
        } else if shot == 3 {
            Tilt.Priority = 1
        }
    }
}