> 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/terrain-samples.md).

# 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="/files/XKobrUH0UysgRhViICDA" 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="/files/DzrLuO1ZIEeB6JGLoxLp" 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.
