The crafting system allows the player to create new items by using recipes.

We’re going to create two Crafting Recipes and allow the player creating them at a special workbench in the game. You can learn more about the crafting system in general in this how-to.

Setting up crafting types

First, we’ll set up two crafting types. They’re used to separate our recipes into different types. Open the ORK Framework editor and navigate to Inventory > Crafting Types.

Crafting Type 0: Alchemy

  • Name
    Set to Alchemy.
  • Description
    Set to: The art of creating potions.

Crafting Type 1: Forging

  • Name
    Set to Forging.
  • Description
    Set to: The art of creating equipment.

And that’s it for the crafting types.

Setting up crafting recipes

Now, we need to set up our two crafting recipes. The recipes define a list of ingredients that are needed to create a list of outcomes. Ingredients and outcomes can be items, weapons, armors and currency. Navigate to Inventory > Crafting Recipes and change the following settings.

Crafting Recipe 0: Revive Potion Recipe

This recipe will use a Potion and a Magic Potion to create a Revive Potion.

  • Name
    Set to Revive Potion Recipe.
  • Crafting Type
    Select Alchemy.
  • Use Chance
    Disable this setting.
    If enabled, the creation of this recipe can be bound to a chance (e.g. by using a formula).

Ingredients

The needed items to create the outcome are defined here. There’s already a default item available, so change it’s settings.

  • Type
    Select Item.
  • Selection
    Select Potion.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.
    You can use the chance setting to decide if an ingredient will be consumed in the crafting process.
    E.g. when setting the chance to 0, the item will not be consumed.

Click on Add Ingredient to add another ingredient.

  • Type
    Select Item.
  • Selection
    Select Magic Potion.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.

Outcomes

The outcome of the recipe is defined here. There’s already a default outcome available, so change it’s settings.

  • Type
    Select Item.
  • Selection
    Select Revive Potion.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.

And that’s it for this crafting recipe.

Crafting Recipe 1: Fire Sword Recipe

This recipe will use a Short Sword, a Fire Scroll and three Magic Potions to create a Fire Sword.

  • Name
    Set to Fire Sword Recipe.
  • Crafting Type
    Select Forging.
  • Use Chance
    Disable this setting.

Ingredients

The needed items to create the outcome are defined here. There’s already a default item available, so change it’s settings.

  • Type
    Select Weapon.
  • Selection
    Select Short Sword.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.

Click on Add Ingredient to add another ingredient.

  • Type
    Select Item.
  • Selection
    Select Fire Scroll.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.

Click on Add Ingredient to add another ingredient.

  • Type
    Select Item.
  • Selection
    Select Magic Potion.
  • Quantity
    Set to 3.
  • Chance
    Set to 100.

Outcomes

The outcome of the recipe is defined here. There’s already a default outcome available, so change it’s settings.

  • Type
    Select Weapon.
  • Selection
    Select Fire Sword.
  • Quantity
    Set to 1.
  • Chance
    Set to 100.

And that’s it for the crafting recipes.

Default Recipe Layout

Displaying a crafting recipes ingredients and outcomes is managed by Recipe Layouts. The default recipe layout is defined in Inventory > Inventory Settings, so let’s navigate there and take a look at it.

Content

The content settings define how the recipe is displayed in general.

  • Content Text
    Set to:
    #text.bold#text.size22#%n#<size#<style#text.bold#text.color2#Ingredient#<color#<style
    %in
    #text.bold#text.color2#Outcome#<color#<style
    %out

This will display the name of the recipe (%n) in bold, bigger letters. The header for the ingredients list (%in) and outcomes list (%out) is displayed in big, yellow letters.

Ingredient Text

These settings define how the individual ingredients are displayed when using the ingredients list text code (%in).

  • Line Separation
    Enable this setting.
    Each ingredient will be displayed in its own line.
  • Ingredient Text
    Set to #text.color4#%n (% / %a)#<color.
    The name (%i), needed quantity (%) and available quantity (%a) are displayed in green letters.
  • Use Not Available Text
    Enable this setting.
    Not available ingredients will be displayed using a different text.
    We can use this to highlight missing ingredients.
  • Not Available Ingredient Text
    Set to #text.color3#%n (% / %a)#<color.
    The text will be displayed in red letters.

Outcome Text

These settings define how the individual outcomes are displayed when using the outcomes list text code (%out).

  • Line Separation
    Enable this setting.
  • Outcome Text
    Set to %n (% / %a).

And that’s it for the default recipe layout.

Adding a crafting menu

Crafting recipes are used through a menu screen. Navigate to Menus > Menu Screens and add a new menu screen.

  • Name
    Set to Crafting.
  • Block Control
    Enable this setting.
  • Single Screen
    Enable this setting.
  • 2nd Call Closes
    Enable this setting.

Part 0: Crafting

Click on Add Menu Part and than on Crafting. This adds a new Crafting menu part to this menu screen. Change the following settings.

  • All Crafting Types
    Enable this setting.

Type Box Settings

  • Type Display
    Select GUI Box.
  • Display Type > Recipe
    Select Same.
    The crafting type and crafting recipe selection will use the same GUI box.

Recipe Box Settings

  • Display Recipe > Create
    Select Sequence.
    The recipe’s content will be displayed after a recipe has been selected.
  • Recipe Box
    Select Menu Small.

Create Box Settings

  • Create Box
    Select Menu Big.
  • Use Choice
    Enable this setting.
    Selecting if a recipe should be used or not is done using choices.
    Otherwise the Ok and Cancel button of the GUI box would be used.
  • Add Back Button
    Select Last.
    A back button is added to the choice (after the Create button).
  • Create Button Name
    Set to Create.

Part 1: Description

Click on Add Menu Part and than on Description. Change the following settings.

  • GUI Box
    Select Top Info.
  • Always Visible
    Enable this setting.

And that’s it for the menu screen. Usually, we’d add the new menu screen to our Overview menu, but we don’t want the crafting system to be accessible in the menu – only in special places in the game world.

Click on Save Settings to save our changes.

Altering the start event

Now, we need to change our start event to teach the player the recipes we just created. Navigate to Events and click on Open Game Event. Select the startEvent and add two Add Recipe steps after the last step of the event (the Learn Log Text step). We also need to add the player as an actor in the Event Settings.

Event Settings

Click on Add Actor to add an actor and change the following setting.

  • Type
    Select Player.

Add Recipe

Add > Game > Crafting > Add Recipe

This step is connected to the Next slot of the Learn Log Text step.

  • Object
    Select Actor.
  • Actor
    Select Player.
  • Crafting Recipe
    Select Revive Potion Recipe.

Add Recipe

Add > Game > Crafting > Add Recipe

This step is connected to the Next slot of the Add Recipe step.

  • Object
    Select Actor.
  • Actor
    Select Player.
  • Crafting Recipe
    Select Fire Sword Recipe.

That’s it for the start event, click on Save Event to save the changes.

The crafting event

We want to open the crafting menu when the player interacts with a workbench in the game world. Create a new game event by clicking on New Game Event.

gametutorial_47_crafting_system1

Event Settings

  • Blocking Event
    Enable this setting.
  • Block Player Control
    Enable this setting.
  • Block Camera Control
    Enable this setting.

Show Dialogue

Add > UI > Dialogue > Show Dialogue

  • Dialogue Type
    Select Choice.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to: Looks like you can create new items here …

Click on Add Choice to add a choice.

  • Choice Text
    Set to: Create stuff

Click on Add Choice to add another choice.

  • Choice Text
    Set to: Nah …

Call Menu Screen

Add > UI > Menu > Call Menu Screen

This step will open a menu screen – the event continues after the menu screen has been closed.

Connect this step to choice 0 of the dialogue step.

  • Menu Screen
    Select Crafting.

And that’s it for the event – click on Save Event and save it as workbench in Assets/Events/Town/.

Scene setup

Open the town scene (1 Town found in Assets/Tutorial Resources/Scenes/). We’ll use a simple cube as our workbench, add one through the Unity® menu: GameObject > Create Other > Cube

gametutorial_47_crafting_system2

I’ve placed the cube in the backyard near the shop and increased it’s scale on the X-axis. Use the ORK Scene Wizard to add an Event Interaction to the cube: Add Component > Event Interaction

In the inspector, select the workbench event we just created in the Event Asset field and click on Ok. The default interaction settings are enough for our event (start type Interaction).

Save the scene.

Testing

Open the main menu scene (0 Main Menu) and hit play. Walk to the backyard and interact with the cube.

gametutorial_47_crafting_system3

You can now create new items at the workbench.

And that’s it for now – the next lesson will cover loot.