# Spawning and pools

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

`scene.Spawn` places a copy of a prefab; `scene.Despawn` returns it to a pool, and the next `Spawn` of the same prefab reuses it instead of building a new one.

    @export var Bullet AssetRef<Prefab>

    func Ready() {
      scene.Pool(Bullet, 32)
    }

    func Fire() {
      b := scene.Spawn(Bullet, node.WorldPosition())
    }

| Function | |
|---|---|
| `scene.Spawn(prefab, pos) NodeRef` | under the scene root at a 2D position |
| `scene.SpawnAt(prefab, parent, pos, rot) NodeRef` | under a parent with a local position and rotation |
| `scene.Despawn(node)` | back to the pool; a node that did not come from a pool is destroyed |
| `scene.Pool(prefab, n)` | build `n` copies now; their `Ready` runs now |
