Cooking System


The Cooking System, introduced in v1.3 is a simple yet robust system that allows the player to cook any item that they have a recipe for, and has the sub-type of food.

How to Set Up

Setting up the Cooking System is super easy.

  1. Inside of the InventorySystem -> Prefabs -> CookingPrefabs folder there will be a CookingUI Prefab. Drag this to your scene. It should already be set up with all the references required as they are all internal to the prefab itself.

  2. Create a new Recipe - Create a new Recipe

  3. Create a new Item for picking up the Recipe OR use code to add it to the inventory.

  4. Set up the Input for toggling on/off the Recipe List.

Let's break down these steps and do it one by one.

Step 1 - Drag the CookingUI Prefab to your Scene. This should be self explanatory.

Step 2 - Create a new Recipe.

Follow the steps in Create a new Recipe to do this.

Step 3 - Create a new Item that the player can pick up that holds the Recipe

Follow the steps in Creating a new Item to do this.

The only two differences are that you'll need to set the Sub-Type to "Recipe" and on the Reactions Tab, you also need to set a "Learn Recipe Reaction" ABOVE the Use item:

Step 4 - Set up the Input for Toggling On/Off the Recipe List

And that's it. That's the basic setup!

How to Use the Cooking System

If you've followed the basic set up, you should have at this point:

  • A Recipe Scriptable Object and Recipe Item Prefab (that you can pick up in the world!)

  • 3 new Item Scriptable Objects - One for Normal Cooked Items, and one for a Perfectly Cooked Item as well as one for your Recipe Item - your items should also have in-world prefabs for dropping/picking up scenarios.

  • Your CookingUI Prefab in Place

Once that's set up, lets put it into action.

Start by placing your Recipe Item Prefab somewhere in the world. For this example I'll be using the Baked Apple Recipe:

You'll notice that I've set the Inventory Item to the BakedAppleRecipe ITEM rather than the recipe, as the item will hold a reference to the recipe:

Next, when in Play Mode, when you go to pick up the item, it will be in the Inventory that you've specified as per the Type in the item.

As long as your Recipe Item has the Learn Recipe Reaction on it, you'll be able to Learn the Recipe:

In your Inventory, click on the Recipe and choose "Use" to Learn the Recipe

If notifications are turned on you'll get this notification:

Next, open up your Recipe List depending on whatever button you've set it to: "Set to L in the Demo Scene", then you'll see your recipe. As long as you have the corresponding items to create the new item, then you can cook it:

There is a cooking minigame included that you don't have to use if you don't want to: To use it, turn off the "Skip Cooking Minigame" bool toggle on the CookingUI -> Cooking Manager component:

If you use the minigame, perfect cook can be achieved via the players input. If you don't use it, it's instead determined by random chance.

The difficulty of the minigame is determined by the Difficulty setting on the Recipe Scriptable Object:

0 is Harder. 1 is Easier. The closer to 0 you go, the smaller the sweet spot will be, whereas the closer to 1 you go, the larger the sweet spot will be.

Last updated