# Scripting

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

    import "aego/camera"

    func OnCollisionEnter(other NodeRef, c physics.Contact) {
      if c.Normal.Y < -0.5 && c.NormalImpulse > 8 {
        camera.Shake(0.35)
      }
    }

    func Boss() coroutine {
      yield camera.BlendTo(BossCam, 1.5)
      yield waitSeconds(3)
      camera.Release(0)
    }

| Function | |
|---|---|
| `Active() NodeRef`, `ActiveOn(output) NodeRef` | the virtual camera that drives an output |
| `BlendTo(camera, seconds) Blend` | make a camera active over priorities and blend to it; 0 uses its Blend Time |
| `Cut(camera)` | the same without a blend |
| `Release(seconds) Blend` | hand the main output back to priorities |
| `Shake(trauma)`, `ShakeOn(output, trauma)` | add trauma |
| `Trauma() float` | trauma of the main output |
| `LogicalPose() Pose` | pose without shake and pixel snapping |
| `RenderPose() Pose` | pose the main output was drawn with |
| `ScreenToWorld(p)`, `WorldToScreen(p)` | conversions with the last drawn view, in output pixels |

`Blend` has `Done()`, `Running()`, `Stop()` and the signal `Completed(finished bool)`; `yield` waits for it. Component methods: `VirtualCamera2D.IsActive()`, `CameraFollow2D.Snap()` and `CameraShake2D.Add(trauma)`.

Each output keeps its own trauma:

```aes run
package demo

import (
    "aego/camera"
    "aego/log"
)

script Outputs {
    func Ready() {
        camera.Shake(0.3)
        camera.ShakeOn("map", 0.9)
        log.Info("main " + string(camera.Trauma()))
        log.Info("active camera is nil: " + string(camera.Active() == nil))
    }
}
```
