Finding items is always a fun thing in games – we can add items to a scene using Item Collectors.
Item collectors can be used in different ways – they can either allow collecting a single item, a random item out of a range of defined items, or work as a box, containing multiple items.
The settings
While item collectors are components used in the scenes, the general item collection settings are made in the ORK Framework editor. Open it, navigate to Inventory > Inventory Settings and change the following settings.
Inventory Settings
We want items and equipment to automatically stack when added to the inventory.
- Add Items Type
Select Auto Stack. - Add Weapons Type
Select Auto Stack. - Add Armors Type
Select Auto Stack.
Item Collection
These settings determine how Single and Random item collectors notify the player about the found item.
- Show Dialogue
Enable this setting.
If disabled, there will be no notification and the item will simply be collected. - GUI Box
Select Bottom Dialogue. - Item Text
Set to You found %n (%).. - Money Text
Set to You found % %n.. - Allow Choice
Enable this setting.
The player can decide to take or leave the item. - Use Choice
Enable this setting.
The item collection will be a choice dialogue – else the Ok and Cancel buttons of the GUI box will be used. - Yes Button Text
Set to Take. - No Button Text
Set to Leave.
Item Box
These settings handle how a Box item collector displays it’s content.
- Take Quantity Type
Select All.
When selecting an item, the whole quantity will be taken without displaying a quantity selection. - GUI Box
Select Menu Big. - Use Add Type
Disable this setting.
When enabled, items and equipment of the same kind will automatically be combined in the item box, but we want to display them as they’re added to the item box’ list. - Allow Cancel
Enable this setting. - Auto Close
Disable this setting. - Empty Box Text
Set to This box is empty.. - Show Exit
Enable this setting.
We’ll display a button to close the box. - Name (Exit Button)
Set to Exit.
And that’s it for the settings – click on Save Settings and close the ORK Framework editor.
Town scene item
Open the town scene (1 Town) and use the ORK Scene Wizard to add an item collector to the scene: Create Object > Item Collector
I’ve placed mine in the grass beside Blue Pants.
Change the following settings in the inspector of the item collector.
- Collection Type
Select Single.
We’ll be collecting a single, defined item. - Scene ID
This should already be set to 0.
The scene ID will keep track of the collection state of the item.
When not using a scene ID, you’ll have to use game variables to remember collected items. - Start Type
Select Interact.
The Item Settings determine the item that will be collected.
- Type
Select Item. - Selection
Select Cure Potion. - Quantity
Set to 3. - Chance (%)
Set to 100.
The Prefab Settings can be used to prevent spawning the item’s prefab or add an extra offset when spawning it. We’ll use the default settings, i.e. spawn the prefab.
Town scene box
We’ll stay in the town scene – now, we’re adding an item box with multiple items in it. First, add a cube to the scene using the Unity® menu: Game Object > Create Other > Cube
I’ve stretched mine a bit and placed it beside Purple Pants.
Use the scene wizard to add an item collector: Add Component > Item Collector
Change the following settings in the inspector.
- Collection Type
Select Box.
The item collector will now automatically receive a Box ID – this ID is used to keep track of the contents of the box during the game (and in save games). Box type item collectors sharing the same box ID will also share the same content.
- Start Type
Select Interact.
Like with the other item collector, the Item Settings determine the items found in the box – but this time you can add multiple items. Change the settings of the already added item.
- Type
Select Item. - Selection
Select Potion. - Quantity
Set to 5.
Click on Add Item to add another item.
- Type
Select Armor. - Selection
Select Cap. - Quantity
Set to 1.
Click on Add Item to add another item.
- Type
Select Money. - Selection
Select Gold. - Quantity
Set to 100.
Click on Add Item to add another item.
- Type
Select Weapon. - Selection
Select Fire Sword. - Quantity
Set to 1. - Chance
Set to 20.
And that’s it for the town – save the scene.
Field scene items
Open the field scene (2 Field) and add some item collectors using the scene wizard.
Yeah, you’re free to add how many you like, place them wherever you like and set up whatever items you like!
Don’t forget to save the scene afterwards.
Testing
Open the main menu scene (0 Main Menu) and hit play. You can now collect items in the town and field.
You can even collect items while fighting in the real time battle area.
And that’s it for now – the next lesson will cover camera events.