Important: in this explanation, the fuse box is used as an example, but this system can be used to create any type of object where to use inventory objects.
Finally, to use the objects created and configure in the previous steps, follow these steps (in this explanation, the fuse box will be used as an example to unlock a door, and the mesh for the fuse box is already created):
The parent that contains the fuse box is an empty transform with this configuration:
The tag assigned is the device. o The layer assigned is Ignore Raycast.
A sphere collider with the trigger option enabled is used to detect if the player is close enough to the fuse box to use the inventory objects on it. So, it looks like this:
Add a Use Inventory Object component to the parent.
In the Main Settings, set to true the option Disable Object Action After Use. This is used to disable the Device String Action component icon, which will be added after.
Also, in the option Use Inventory Type, you can configure how the objects used in the fuse box are placed:
Menu, the player needs to open, select and use the object.
Button, the player only needs to press the interaction button to use the necessary inventory objects (in case he has them, else a message is shown on the screen to say that the player hasn’t the needed objects).
Automatic, the player only needs to enter the trigger to use the inventory objects in the fuse box.
Add an event to the list of Unlock Function Call and add the object to use, in this case, add the door to unlock.
Add in the Function field, and set the UnlockDoor function, from the component Door System.
Now, configure the objects to be used from the inventory in this fuse box. For this follow these steps: o Open the Inventory Object To Use Lis.
o
Press the button Add Object.
Open the new element and configure the values required, name, the amount needed, and the message shown on the screen when the object is used.
Then, in the field Object Needed, drag and drop the mesh of the inventory object which needs to be used here, in this case, the fuse. The path of these meshes is Assets/Game Kit Controller/Prefabs/Inventory/Mesh
Open the Inventory Object Needed List inside the current element that is being configured and press the button Add Object.
Open the new element and, for this case, set to true the option Enable Object.
This option activates a gameObject in the level and in this case, the fuse models placed in the fuse box are disabled, so when the player uses a fuse from the inventory, the fuse is activated inside the box. For this example, the gameObject Fuse Model is disabled in the hierarchy. This is the element configured in the Object To Enable Field.
The fuse model needs to be disabled before starting the game.
Instead of activating disabled gameObjects, there is an option to instantiate objects in the scene, but this will be explained later.
In this case, there are four fuses, so configure the rest of them, like the first one.
Now, along with the four fuses, the fuse box needs a blue wire to work, so another object needs to be configured, but it is another element different from the fuses. Go to the main Inventory Object Needed List and press the Add Object button to configure the blue wire.
For the blue wire, like for the fuses, configure the name, the message to show on screen and the amount needed and the inventory object mesh to use.
And inside the Inventory Object Needed List, configure the object to active, in this case, a mesh of the wire already placed in the box, like the previous fuses objects.
Like with the Fuses Models configured before, the wire object needs to be disabled.
Finally, add a Device String Action component to the parent, with the next configuration.
The Device Name and the Device Action are the text shown in the icon of the interaction button on the screen. The Show Icon is the default option to show that icon on the screen. The Show Touch Icon Button is a default option used to show the touch button on mobile devices to use the interaction button.