I need help on a starting point to make a crafting system using blueprint or C++. I have an inventory system made already with blueprint, with a rock and a log as 2 of my objects right now. Can someone please point me in the right direction on how to make it to where I can add those 2 together to make a simple hatchet. I have the hatchet as an item but its not coded yet for my inventory…
Thanks,
Charles
What are you asking fir is actually pretty simple and there no magic involved!
First you must decide how you will store information about your crafting componenets. Objects, Actors, structs ?
Then, you must find a way to identify types of components, to make right interaction between them. There are essentialy two way I can think:
-
Create separate subclass for each type of component. I don’t recommend this approach.
-
Use GameplayTags module.
Assuming you pick up option three, you will need to create your basic UCraftingComponenet class, or something like that. In that class add
FGameplayTagContainer OwnedTags;
FGameplayTagContainer RequiredTags;
Owned tags are tags, that this crafting component owns. Required tags, are tags that other crafting componenet must have to interact with this component.
Then you will need to add some delegate events, which will send around Tags, when componenets are added togather.
You might also want to create something like Master crafting class, which will handle all interaction between componenets. Like adding them to array by player, and then checking and comparing tags to see if there is any possible outcome.
You will probably need to iterate a bit and check things out, as I have never done crafting system, though I have similar system for creating spells, feats, skills, weapons etc.Albeit I haven’t exposed it players only to blueprints.
In anycase to general rule is to:
- Identify types of object.
2, Compare objects with each other to check if they meet their requirements.
- If the objects meet recipe (container of required tags in final item), that item can be created.
Do you have an example pic? I really need a point in the direction on the components.
This will only work for C++. To use GameplayTags you will need to load them at editor start, and to do that, you will need custom Engine/EditorEngine classes.
Coding them is fairly easy:
As for componenets. I don’t mean an componenet added in componenets panel ;). I mean just very simple class which contain data, about what it is, and with what it can interact.
The general idea, is that you add crafting objects into single array, and then check if they match required composition to actually craft (spawn) another object.