> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Runtime Object Spawning

AirGen can instantiate new actors at runtime, enabling procedural scene generation and on-the-fly environment augmentation.

```python theme={null}
import airgen
from airgen.types import Pose, Quaternionr, Vector3r

client = airgen.RobotClient()
client.confirmConnection()
```

## Discover Assets

`simListAssets` queries the Unreal asset registry. Supply a regular expression to filter matches.

```python theme={null}
meshes = client.simListAssets("StaticMesh'.*Crate.*")
print("Found", len(meshes), "crate meshes")
```

## Spawn Project Assets

`simSpawnObject` places an asset that ships with the current map.

```python theme={null}
crate_name = client.simSpawnObject(
    object_name="crate_runtime_01",
    asset_name="/Game/Props/Crates/SM_Crate_01.SM_Crate_01",
    object_tags=["movable", "loot"],
    pose=Pose(
        position_val=Vector3r(0.0, 2.5, -0.5),
        orientation_val=Quaternionr.IDENTITY,
    ),
    scale=Vector3r.ONE * 1.25,
    physics_enabled=True,
)

if crate_name:
    print("Spawned", crate_name)
```

* **`object_name`** — Desired actor name; pass an empty string to auto-generate.
* **`asset_name`** — Unreal asset path.
* **`object_tags`** — Optional tags for later filtering.
* **`pose`** — [`Pose`](/simulation/airgen/features/data-types#pose) in world coordinates.
* **`scale`** — Uniform or per-axis scaling with `Vector3r`.
* **`physics_enabled`** — Enable physics on spawn.

## Spawn External Meshes

Load glTF/glb meshes from disk or the web at runtime. Both variants return the spawned actor name on success.

```python theme={null}
runtime_desk = client.simSpawnObjectFromPath(
    object_name="Desk_GLB",
    path="/tmp/assets/desk.glb",
    pose=Pose(
        position_val=Vector3r(3.0, -1.0, -0.9),
        orientation_val=Quaternionr.IDENTITY,
    ),
    scale=Vector3r(1.0, 1.0, 1.0),
    is_unlit=False,
    physics_enabled=False,
    complex_collision=True,
    nav_enabled=True,
)

asset_url = "https://example.com/models/cone.glb"
client.simSpawnObjectFromURL(
    object_name="ConeFromURL",
    url=asset_url,
    pose=Pose(
        position_val=Vector3r(5.0, 0.0, -0.5),
        orientation_val=Quaternionr.IDENTITY,
    ),
)
```

* **`is_unlit`** — Disable dynamic lighting (useful for emissive billboards).
* **`complex_collision`** — Use triangle-mesh collisions instead of primitives.
* **`nav_enabled`** — Include the mesh in navigation mesh generation.

## Adjust Materials at Runtime

After spawning, update materials or textures without reloading the asset.

```python theme={null}
client.simSetObjectMaterial("crate_runtime_01", "M_WorldGrid")
client.simSetObjectMaterialFromTexture(
    object_name="crate_runtime_01",
    texture_path="/Game/Textures/T_OrangeGrid.T_OrangeGrid",
)
```

Use `simSetObjectMaterialFromTextureURL` to stream textures from remote sources.

## Clean Up

Destroy objects when they are no longer needed.

```python theme={null}
client.simDestroyObject("crate_runtime_01")
```

Destroying and respawning actors is inexpensive and works well for randomized data-generation loops.

***

Pair runtime spawning with [Pose Control](/simulation/airgen/features/pose-control) to position assets precisely before capturing data.
