> For the complete documentation index, see [llms.txt](https://flora.magneticarcade.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flora.magneticarcade.com/samples/runtime-samples.md).

# Runtime Samples

## Fish Boids

The Fish Boids scene demonstrates runtime-driven instance animation at high counts using Flora + jobs.

<figure><img src="/files/aivaH4mTPFHQFme0I4pa" alt=""><figcaption></figcaption></figure>

### Scene Path

`Samples~/Examples/Fish/Scenes/FishBoidsSample.unity`

### What This Demonstrates

* Runtime creation and ownership of many instances
* Job-based transform simulation
* Batch update upload into Flora runtime

### APIs Exercised

* `FloraSystem.GetOrCreate()`
* `CreateInstances(...)`
* `ScheduleUpdateInstanceWorldTransforms(...)`
* `DestroyInstances(...)`

### Run and Verify

1. Open `FishBoidsSample` and press Play.
2. Confirm fish schools animate continuously.
3. Watch frame stability while instance counts are high.

**Expected result:** fish move smoothly as Flora instances without per-fish scene GameObjects for rendering.

### Common Failure Checks

* No fish visible: ensure Flora is active and sample objects enabled.
* Errors on disable: verify job dependencies complete before destroy/dispose.
* Motion vector artifacts: check runtime/scene motion-vector settings.

### Core Classes

#### FishSchool

```csharp
NativeArray<FloraInstanceTransform> m_Transforms;
NativeArray<FloraInstanceHandle> m_InstanceHandles;
JobHandle m_Dependency;

void OnEnable()
{
    m_Transforms = new NativeArray<FloraInstanceTransform>(SpawnCount, Allocator.Persistent);
    m_InstanceHandles = new NativeArray<FloraInstanceHandle>(SpawnCount, Allocator.Persistent);

    FloraSystem.GetOrCreate().CreateInstances(Prefab, gameObject, m_InstanceHandles, m_Transforms);
}

void OnDisable()
{
    m_Dependency.Complete();
    FloraSystem.Instance?.DestroyInstances(m_InstanceHandles);

    m_Transforms.Dispose();
    m_InstanceHandles.Dispose();
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://flora.magneticarcade.com/samples/runtime-samples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
