# Terrain Samples

These scenes demonstrate terrain tree interaction workflows driven by Flora instance APIs.

***

## Tree Effect

This sample animates terrain tree instances inside a spherical influence volume.

<figure><img src="https://2882982566-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyo4B7EVXffipTxnJzee6%2Fuploads%2Fgit-blob-249e1e990341a555f5b7186e58807cf3e06f55df%2Ftree-effect.webp?alt=media" alt="Tree Effect sample"><figcaption></figcaption></figure>

### Scene Path

`Samples~/Examples/Terrain/Scenes/TreeEffectSample.unity`

### What This Demonstrates

* Tree instance query by sphere
* Local-to-world retrieval and update
* Per-instance runtime animation without converting trees to scene objects

### APIs Exercised

* `FindInstancesIntersectingSphereMatching(...)`
* `GetInstanceLocalToWorlds(...)`
* `UpdateInstanceLocalToWorlds(...)`
* `FloraInstanceFilter.ByTrees()`

### Run and Verify

1. Open `TreeEffectSample` and press Play.
2. Move/observe effect sphere region.
3. Confirm nearby trees animate and recover when leaving the region.

**Expected result:** only trees in-range are displaced/animated.

### Common Failure Checks

* No response: verify `EnableTerrainFoliage` and terrain auto-registration.
* Trees remain offset after stop: check cleanup/restore path in sample script.

***

## Tree Wrecking Ball

This sample demonstrates physics interaction that disables terrain-tree instances and spawns replacement rigidbody objects.

<figure><img src="https://2882982566-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyo4B7EVXffipTxnJzee6%2Fuploads%2Fgit-blob-a2bba4f9606ad4a2dfa6b0a9bd555d867445cada%2Ftree-wrecking-ball.webp?alt=media" alt="Tree Wrecking Ball sample"><figcaption></figcaption></figure>

### Scene Path

`Samples~/Examples/Terrain/Scenes/WreckingBallSample.unity`

### What This Demonstrates

* Collision-region tree query
* Instance enable/disable control
* Runtime replacement with `GameObject` + `FloraInstanceRenderer`

### APIs Exercised

* `FindInstancesIntersectingSphereMatching(...)`
* `SetInstancesEnabled(...)`
* `GetInstanceWorldTransform(...)`
* `GetInstanceIdentitySource(...)`
* `GetInstanceOwnerTerrain(...)`

### Run and Verify

1. Open `WreckingBallSample` and press Play.
2. Let wrecking ball collide with trees.
3. Confirm impacted trees are hidden as Flora instances and replaced with rigidbody objects.

**Expected result:** collision zone trees convert to physics-driven replacements; Flora instances are disabled.

### Common Failure Checks

* Trees never disable: verify query region radius/position is valid.
* Replacements missing Flora rendering: ensure `FloraInstanceRenderer` is added and prefab assigned.


---

# Agent Instructions: 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:

```
GET https://flora.magneticarcade.com/samples/terrain-samples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
