You’re talking about an entire system here which might be beyond the scope of AH.
Is there a particular element you’re having problems with? Is it safe to assume you’ve got the drag & drop mechanic in place already and are just unsure how to execute the combining part?
Also, are your items just widgets? Or an in-game item is an actor who is then represented by a widget in the inventory?
Well, I have been with this problem for a long time and I hope someone helps me, I have followed a tutorial on how to make an inventory, so that my goal was the crafting of items, but not exactly that, my idea was to combine items to create others and generate objects that can trigger events, for example: lighter + gas = charged lighter, use that lighter to light a torch etc, same with keys to create puzzles, my idea is to create a silent hill style inventory system. The problem is that I have no idea how to create the object combination system, I use a grid panel for my slots in the inventory, my idea is to drag the object with another in the inventory and create a new one but I don’t get any information from How to do this mechanic, I hope someone helps me. Thanks for your time.
I already have the mechanics of picking up objects and dropping them, also the mechanics of dragging objects to drop them, I have no idea how to drag the objects into the inventory and combine them
Here, the Combines With variable holds a list of item types that can be combined with this particular item. The types are paired with classes. If an enumeration match is found, Find returns the appropriate class.
Let’s say the above is in the Item actor. When you drop, have the widget dispatch the payload actor (or widget references - not sure how you handle things) and call Check Combination; if the dropped item’s type is present in this item’s Map, a new item is Spawned and both ingredients are Destroyed. If whatever we dropped does not combine with a stick / rag / bandage (it was not on this item’s list), nothing happens.
This might be a good enough concept if you have 10 items with 3 combinations each.
If we’re talking about hundreds of items with 1k+ potential combinations, you’d need a database with recipes. To do it properly, you’d have an inventory manager actor dedicated to producing result of a combination. Feed the manager items to combine, it would then query the appropriate data sets and spit out the result. This way you could keep this logic in a single manager actor rather than every item actor.
Again, how to design a system like this would depend on the scope first of all and then on the required complexity.
You will need a good understanding of blueprint comms, for sure. When actors are represented by widgets, Event Dispatchers are a must. If you’re dealing with inheritance and want unrelated classes to communicate, you will need to implement Interfaces.
Maps are a solid choice for this kind of thing, very efficient at finding stuff. If you ever need to combine more than 2 item in a pool of other items, Sets are super handy.
It’s also somewhat difficult to advise precisely as I do not know how you’ve build the inventory system so far.
In a typical scenario where an Item is an Actor that is represented by a Widget in the UI, you’d have a the Item create its Widget which then communicates with its owner via an Event Dispatcher.
When a widget detects the drop operation, it fires a dispatcher (with the information about the dropped on item) which is then caught and processed by the actor. In this case I’d implement what I originally suggested in the Item Actor itself. This way you can rely on inheritance and can spawn Item Actors with their own type and combination lists. An Item Actor base class could look like this:
Item Actor:
enumerator Type
Map Combination List
Widget reference
As a general rule of thumb, widgets should contain little script while actors do the heavy lifting and display results in their widgets. Widgets can format text, apply colours, show icons and whatnot, handle drag & drop ops, send interaction request back to their owning actors - the latter being this very case here.
My god, how difficult is all this, I need to study how to create these maps and implement them, so that when I drop the object in the box and that creates an interaction, I have to do it with the widget itself or with the payload? and this is implemented inside the slots of the widget? in this case the grid panel?
and how to get the information of each slot in the grid panel and how to implement this from each slot and every time I drop the object in that box one of my biggest problems is that I don’t know how to get this information. this is really a puzzle
the inventory Actor has a Widget - a grid with slots
the inventory holds an array of Item Actors
each Item Actor has a Widget
That’s why I mentioned blueprint communications earlier on. I don’t think you have a problem with combining items per se (not yet!), you may need to take a step back and ensure you can produce an effortless data flow between the player, its inventory, the items inside and the world the items interact with.
There’s yet to be a ay where I don’t draw a data flow diagrams on a piece of paper. Only to realise a month later that I failed to account for something
Now with this I see much more meaning, I have to start studying all this but I think this is the solution I need, I will try to implement all this and I leave you the tutorial that I have followed so that you can see exactly how my Inventory
The step I’m through now is in the crafting video, because I don’t want it to be that way, in fact I have visually changed some things but I haven’t followed because the crafting mechanics is not what I want, at least that one form, if not how I have explained it to you
If you recommend any tutorial that resembles what I am looking for, I would be eternally grateful, also, thank you very much for all this information, you have helped me a lot, thank you very much