> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/unity-integration/point-data/spawn-objects-from-point-data.md).

# Spawn objects from point data

Use SPNet Point Spawner to create a Unity object for each point received from Grid Studio.

Choose a reference prefab or scene object, and the spawner creates and updates its copies using the incoming point IDs, positions and orientations.

This example uses Point Data Object ID `1`. Start with the connection described in **Connect Grid Studio and Unity**.

{% content-ref url="/pages/Ja1auhvBW5GmFp7vcqtE" %}
[Connect Grid Studio and Unity](https://stage-precision.gitbook.io/grid/unity-integration/getting-started/connect-grid-studio-and-unity.md)
{% endcontent-ref %}

#### Send point data from Grid Studio

1. Select a **Volume** with a point-data input, or a **Point Cloud Volume** producing tracked points or clusters.
2. In **Maps**, add an **SPNet Point Data Map Output** and assign your SPNet sender.
3. Set the outgoing object ID to `1`.
4. Choose **Global** coordinates for this example.

Each Point Data output contains a group of points with individual point IDs. Use a distinct outgoing object ID for each Point Data stream on the same connection.

<div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2FynMrF6zIAVws3fKHEDkE%2FPowerToys_znGda7fP91.gif?alt=media&amp;token=5a29e9e1-cad8-4152-9ca3-f1ca20c607fa" alt="" width="411"><figcaption></figcaption></figure></div>

{% content-ref url="/spaces/A6FCGfFOA45eEE2SR3Sp" %}
[Spatial Interactive Experiences](https://stage-precision.gitbook.io/grid/spatial-interactive-experiences/)
{% endcontent-ref %}

#### Choose a reference object

The **Reference Object** defines the appearance and components of each spawned copy.

You can use a prefab from the Project window or an ordinary GameObject from the Hierarchy. For a simple example, use a cube.

To create a reusable prefab, drag a scene object from the Hierarchy into a folder in the Project window.

#### Create the spawner in Unity

1. Choose **GameObject → SPNet → Point Spawner**.<br>

   <div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2F9oPxCjh9ubklxA1wVnGu%2Ffcg5m43tLf.gif?alt=media&amp;token=68c5104b-7cc9-4ca4-a6a1-eb4fafc3a2d4" alt="" width="332"><figcaption></figcaption></figure></div>
2. Select the new **SPNet Point Spawner** in the Hierarchy.
3. Set the **Object ID** to the same number like the Grid Studio SPNet map out.<br>

   <div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2FuPP0BkiCARsnFfUMjdV1%2FPowerToys_eqwptYucHb.gif?alt=media&amp;token=7a8844a3-48df-48fa-845e-be93a4380093" alt="" width="541"><figcaption></figcaption></figure></div>
4. Drag your prefab or scene object in to **Reference Object**.<br>

   <div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2FhPfELaxT772ftIuUoZee%2F10LEAXKrgT.gif?alt=media&amp;token=956ffec9-1f23-41a2-aa20-9f0af60c3922" alt="" width="541"><figcaption></figcaption></figure></div>
5. Enter **Play mode** to spawn the objects.

The Receiver is assigned automatically or created when needed.

**Object ID** selects the complete Point Data stream. Individual point IDs are handled automatically by the spawner.

During Play mode, each incoming point gets its own copy. Further updates move the copy associated with that point ID. Copies disappear when their points are removed or the source times out.

Spawned objects appear below the Point Spawner in the Hierarchy. Their received positions and rotations are applied in Unity world coordinates.

<figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2FxzERYk8lAiDaMwbiUJDa%2Fx7my8Olm8G.gif?alt=media&amp;token=97a1d52a-c664-4716-84f4-b52edbb810e5" alt=""><figcaption></figcaption></figure>

#### Use received size and color

Both options are disabled by default.

| Setting         | Effect when enabled                                                      |
| --------------- | ------------------------------------------------------------------------ |
| **Apply Size**  | Uses each point's received XYZ size as the copy's local scale.           |
| **Apply Color** | Applies each point's received color to compatible materials on the copy. |

With **Apply Size** disabled, copies use the reference object's scale. With **Apply Color** disabled, they use its material colors.

For received color, use a material with a compatible base-color property, such as URP Lit.

#### Point events

Expand **Point Events** to connect callbacks for individual points.

| Event                | When it runs                                                        |
| -------------------- | ------------------------------------------------------------------- |
| **On Point Added**   | A new point ID enters the received set.                             |
| **On Point Updated** | An existing point receives updated data.                            |
| **On Point Removed** | A point is removed, the source times out or the point set is reset. |

Events provide the point's ID and tracking data. Use them with your own Unity components to trigger effects or build interactions around tracked people and objects.

Point events run in **Play mode**.

<div align="left"><figure><img src="https://1380116828-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc4nPw8BslCHXa7bL2mf8%2Fuploads%2Fn2dHAwFF9kcNq3T7yaOM%2FRlD9WlVR7U.gif?alt=media&amp;token=dc36804e-aa48-4346-95e3-2bd632cf7e74" alt="" width="314"><figcaption></figcaption></figure></div>
