this is a very simple crafting system open source package for Unity3D.

You can find the source code here: https://gitlab.com/z3r0_th/crafting

To use it as a package, just open manifest.json (from YourProject/Packages folder) and add just below  "dependencies": {
as such:

"com.matheusfernandestech.crafting": "https://gitlab.com/z3r0_th/crafting.git#upm ",

Now you can click with right click on any sprite and create an ingredient (that can be used in recipes). A recipe is a set of ingredients, that result in another ingredient (one or more). And a book is just a set of recipes. 

So you can declare a log being an ingredient and a wooden plank being an ingredient as well. Then declare a recipe with four wooden plank as a Result of a Log ingredient. 

Crafting example

a simple example in unity3d

You can check the possible recipes from a list of ingredients:

var recipes = book.GetAllPossibleRecipes(ingredients);

and from the recipe you can get the result ingredient and basic ingredient amount. And how many you can make with a list of ingredients.

SetResult(recipe.Result, recipe.Amount, recipe.HowManyResultsWith(ingredients));

Example:


Leave a comment

Log in with itch.io to leave a comment.