How To Spawn Objects

Mesh collider tip

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.

How to spawn objects

  • 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)

  • Create an empty GameObject which will act as your spawn point for the item (This can be inside your drawer

  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)

  • 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

You can add additional items to spawn by clicking the + icon if you wish

Last updated