Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Once everything is configured, the fuse box can be tested. For this, go where it is placed and follow these steps:
Make sure to have at least 4 fuses and 1 blue wire in the inventory.
Enter inside the device trigger, open the menu and press the Fuse object.
Press the button Use, select the amount to use with the buttons + and - (it can be one by one, two, any amount from the available in the inventory). You can press also X to close the amount window.
Press Use again. The fuses are activated and the message configure is shown.
Open the inventory again, select the blue wire and use it.
As you can see, every message is shown according to the object used. Like this, all the elements needed are placed and the door is unlocked. Also, in this case, when the door is unlocked, the map icon in the minimap changes.
Select the Character gameObject in the GKC_Prefab.
Go to Inventory List Manager inspector and open the inventory list.
Press the button Add Object.
Open the new object and configure the Name and description.
Then, create the mesh used for that inventory object. It needs to have these settings:
The mesh or meshes used in the object are placed in an empty parent, with a scale (1,1,1).
That parent needs to use the layer inventory.
That parent needs a collider adjusted to the object's shape and size. You can add as many collider (box, sphere, capsule) as you need if the objects has a complicated shape, but all these colliders need to be configured in the parent.
This is not necessary, but the name for the prefab can be the name of the object with Mesh and the end.
For example, this is the red wire created.
Once it is created, drop it to the prefab folder in the path Assets/Game Kit Controller/Prefabs/Inventory/Mesh.
Go back to the Inventory List Manager, and set the mesh of the new object with the one created previously in the field Inventory Object Mesh.
Finally, press the button Create Inventory Prefab to create the prefab of this object, which is the pickup ready to be dragged and dropped into the scene to be used by the player.
In this final step, the prefab is stored in the path Assets/Game Kit Controller/Prefabs/Inventory/Usable. Also, this prefab is assigned automatically in the new inventory object created in the Inventory List Manager.
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.
Now, press the button Open Inventory Capture Tool, so the mesh created is rendered in the window to take a picture of it.
Configure the resolution of the image (the default value is 1024x1024) and the name of the capture. Also, you can use the values of position and rotation to rotate the object for a better perspective and move its position to place it correctly inside the capture. Once it is configured, press the button Get Capture.
In the folder path Assets/Game Kit Controller/Prefabs/Inventory/Captures, the new icon is stored. Also, the icon is assigned in the new inventory object in the Inventory List manager.
Then, configure the values for the object if can be used, equipped and/or dropped. The option Amount Per Unit is used normally for elements like fuel, where the player has for example 10 cans and every can has 10 liters. The Infinite Amount is used to set the inventory object with infinite uses.
Let's look at how to assign new inventory objects in the player’s inventory manager. Once the new inventory is created, to be usable by the player follow these steps:
Go to Player Controller gameObject.
Go to the inspector Inventory Manager and open the Inventory Manager List.
Press the button Add object.
Configure a name for the object that you want to add from the Inventory List Manager and the amount.
Press the button Get Inventory Manager List, to get all the inventory objects configured in the Inventory List Manager (this need to be done every time a new inventory object has been added if you want to add it to the player’s inventory).
You can check the difference between the list show in the field Object Name before and after.
Finally, in the field Object Name, select the new object created in the Inventory List Manager (or the one you need from the previous elements in that list).
To check if everything works, press play an open the inventory menu (by default is the I key). The new inventory object (in this case, the red wire) is shown in the grid and it contains the information configured, the amount, it can be used and dropped.