How To Spawn Objects
Last updated
Last updated
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.
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
Add the ItemSpawner script to this empty gameobject spawn point
Add the item prefab you want to spawn in the appropriate array
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