# How To Spawn Objects

### Mesh collider tip

{% hint style="warning" %}
Make sure the drawer has a mesh collider because you don't want a larger collider (Like a box or sphere collider) blocking the interaction.&#x20;
{% endhint %}

### How to spawn objects

{% hint style="info" %}
* Go to the **DoorInteractable** script and tick the **Spawn Items** checkbox at the bottom (This will open the additional parameter for items you can spawn)
{% endhint %}

<figure><img src="https://540954588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fpn2t9ISWRkG5tw4D8S4w%2Fuploads%2FWJQUDC5rCy8ysvZdz4CW%2FSpawnCheckbox_V1.2.JPG?alt=media&#x26;token=31cb296d-8c75-4bfb-bd10-d491d069c948" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
* Create an empty GameObject which will act as your spawn point for the item (This can be inside your drawer
{% endhint %}

<figure><img src="https://540954588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fpn2t9ISWRkG5tw4D8S4w%2Fuploads%2F74XV1zWtgKEBwLiDQjgf%2FSpawnLoaction.JPG?alt=media&#x26;token=ee1f8058-9fd4-43df-9f13-d84bb96b5b4b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
1. Add the **ItemSpawner** script to this empty gameobject spawn point
2. Add the item prefab you want to spawn in the appropriate array
3. Add the spawn point gameobject to itself as this will be the transform. (I use the additional variable in case you want to spawn via another location)
{% endhint %}

<figure><img src="https://540954588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fpn2t9ISWRkG5tw4D8S4w%2Fuploads%2FQ62j0JuZ4Fy5epdH4ofM%2FItemSpawner.JPG?alt=media&#x26;token=4c24115f-d92c-447a-8b5b-123f91a73f39" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
* Go back to your **DoorInteractable** object and add the empty gameobject spawn point to the **OnDrawerOpen()** event box, then select the **ItemSpawner > SpawnItems** from the dropdown box
{% endhint %}

<figure><img src="https://540954588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fpn2t9ISWRkG5tw4D8S4w%2Fuploads%2F6jgOktcTLzK6uDe2ivNc%2FSpawnItems.JPG?alt=media&#x26;token=b0ea9328-99e6-4d17-94f1-67863c50de6a" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
You can add additional items to spawn by clicking the **+** icon if you wish
{% endhint %}
