# Instance Transform

`FloraInstanceTransform` is a lightweight struct used to represent an instance’s **position**, **rotation**, and **scale**—either relative to a parent (`local space`) or in world space when no parent is assigned.

Its design and API are based on Unity’s [`LocalTransform`](https://docs.unity3d.com/Packages/com.unity.entities@1.0/api/Unity.Transforms.LocalTransform.html) from the Entities package.

***

### Usage

#### Defining an Instance Transform

Instances can be placed using local-space transform data relative to a parent `Transform`:

```csharp
var localTransform = new FloraInstanceTransform(localPosition, localRotation, localScale);
FloraSystem.Instance.CreateInstance(prefab, this.transform, localTransform);
```

#### Converting from a Unity Transform

You can construct a `FloraInstanceTransform` from a `Transform`, in either local or world space:

```csharp
var local = FloraInstanceTransform.FromUnityTransform(this.transform, Space.Self);
var world = FloraInstanceTransform.FromUnityTransform(this.transform, Space.World);
```

#### Writing Instance Transforms

To update an instance’s transform after creation:

```csharp
FloraSystem.Instance.UpdateInstanceWorldTransform(handle, transform);
```

You can also update multiple instances at once using arrays or native containers.

#### Transform Composition and Manipulation

`FloraInstanceTransform` includes utility methods for manipulating transform data:

```csharp
transform = transform.RotateY(math.radians(90)).Translate(new float3(0, 1, 0));
```


---

# 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/scripts/instance-transform.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.
