Crafting System and First Person Object placement for Unity
Playable WebGL: http://RaulMrSouza.github.io/SimpleCraftWebGL
I am building a top down survival game with a friend for 1-2 players, similar to How to survive (using Unity 2018.3.8f1 because of the Book of the dead asset). I want to support keyboard/mouse as well as (xbox) controller inputs. A quick video featuring the building system from the Ultimate Survival asset, it doesn't showcase everything, but it should be a good indicator. Music: The Who - Eminence Front Game.
Package: https://github.com/RaulMrSouza/SimpleCraft/blob/master/SimpleCraft.unitypackage
Asset Store(old version): https://assetstore.unity.com/packages/templates/systems/simple-craft-system-107967
Video: https://www.youtube.com/watch?v=V9Pm6ZkJ0Yc
The gameplay idea is that the player will use Tools to gather Resources in orderto build Craftable Items or more Tools.
The project purpose is to be simplistic and easy to be expanded. In other words, easyto add more resources, tools and craftable items.
It is not required to know scripting to use and expand this asset.
The Demo scene is a good way to see how it works
Now some information about the project:
![Unity asset store Unity asset store](/uploads/1/2/6/3/126381007/621191607.png)
To properly run the Simple Craft system on a scene it is required to have thefollowing prefabs:
- Resources;
- Craftable Items;
- Tools;
- a Settlement Manager;
- a Character;
Items are the base prefabs in the crafting system, they can be grabbed intothe inventory and used for other purposes.
To create a new item just create an Item scriptableObject using Create->SimpleCraft->Itemand set a Prefab with a Collider and an Item Refence script to be the physical object ofthe Item.
Each Resource has a amount of a certain Item. when gathered with a tool the Itemswill be transferred to the player's inventory.
It must have a cost in Items to be crafted. For instance, a table costs planks to becrafted, and the plank cost woods.
Each possible craftable item in the scene must be on the Manager's Items structure,so that it can be instantiated.
The process of creating a new Craftable Item is equal to create a new item plusfilling the craft cost, one thing that can be tricky it's the position, the object'spivot should be right bellow the object components while the detection collidershould be placed where it can validates where the object can be crafted, look atthe already existing craftable Items to have an example.
A tool is a craftable item.
Each tool has a GatherFactor which is used to define which resources the toolis good or bad to use at. For example, in the default tools, the axe is betterto gather wood, the pickaxe better at gold and stone and the hammer is neutral.
The tool requires that the main object or one of its children has a triggercollider, which will be used to detect collisions between the tool and resources.
It is responsible for the instantiation of craftable Items, therefore theinstantiation of tools.
Each craftable item, including tools, must be on the Manager's Items structure.
They must be separated in categories, the default are furniture, tools, buildingsand materials, more can be added in the editor.
The Manager also can be used to check the goal of the scene with the prpertyobjectiveItem. Check the Demo scene to better understand this feature.
The default character has a Player.cs script in the camera, already set to work with a tool handler and a fps style character controlerand the canvas objects.
The Player has an Inventory of Items that can be used to build new CraftableItems and can equipa tool.