I am trying to make chests work with my inventory. I have a Parent Chest Blueprint that has a 3D widget component that shows the items added.
What I want to do: I want to have a single Interface for tracing chests, and then have the item added in any chest separately.
What actually happens: Whenever the “Chest Interface” is traced, the item slot is added to the oldest Chest in my level, and not the one I am actually tracing.
I believe it has something to do with 3D widgets. I don’t want to make a different trace and interface for every chest because when I have 100 inventory items and add a new chest, I would have to add new code to all the 100 items to fit in the new chest, and I know that’s not the way. What am I missing? Photos coming up!
This is in Chest Parent BP:
first what do you mean by trace? are you talking about the script? a trace is something like a line trace to do tests so your explanation is a bit confusing.
that said i would think that at least part of your issue is your method of getting a reference to the chest. by using the get all of class and get 0 in combination it will likely return the chest with name closest to A or the oldest. in either case its a poor way to get a reference.
Im not really clear on your situation (what your attempting) so i could be a bit off in my thinking so i dont want to go into it too much. It seems like you have a different widget created for each item which seems odd. would it not be easier to store item information in a array of structs such as (name, image, BPActor, weight, etc) then you create one widget which displays item info and use a loop to populate the inventory for each item (each item will create a instance of the item info widget and add it to a parent inventory widget).
Hello, thanks for your insight! I will try to explain more. I use a trace for my interactions, what I meant was that I want to have a single trace (trace for chest) and not one for each chest I have in the level.
Also, I want to have a different Chest Slot for each item because I want to have them have custom code because my items can be combined with other items in the world (like in old adventure games). There are slots that are expirable, stackable, non stackable, and I only have problems with the stackables which use the arrays. I only pull name and quantity from a structure.
Right now, I put the code in the photo in every new child chest instead of inside the parent, and I can add stackable items in the chests ok. But when I pull one out, all the chests go down by one because I have the slots pull their quantities (for the quantity number of the widget) from chest 1 and chest 2 at the same time. I know you don’t understand anything, I barely can. Structs and arrays are so hard to work with! Thanks for your time, I know I won’t solve it any time soon
!
I want to have a single trace (trace for chest) and not one for each chest I have in the level
if you mean a line trace then you could use the tag system, basically add the tag “chest” to all the chests then when you get the hit result from your trace you would check to see if the actor has the tag. though that seems like poor way to do it imo. i would probably use something like a bp interface with something like a use function and have the chests figure out what they need to do based on the interface call. or you could re-parent your chests to have a common parent.
I want to have a different Chest Slot for each item
that sounds like inventory slots to me, like in wow or resident evil 4.
overall it sounds like your just trying to make a basic inventory but over complicating things. for a normal inventory, you would store then items contained in the chest in a array. the array would be of a struct type and the struct would hold the information needed such as name and quantity. no matter if your removing or adding items you target the one instance of the chest actor so it shouldn’t affect any others. you are talking about treasure chests right.
ok so its a storage system. basically its a two way inventory. are all the chests going to share one inventory, like if you put something in chest 1 will you be able to remove it from chest 2 or are they all independent.
Not exactly treasure chests, I am trying to make storage chests, different inventories that the player can store items and come back to them later. I know it’s tough so any more tips welcome!
The idea is to have them all independent! Chest 1 objects can be removed only from chest 1.
The biggest problem I found so far is how to show the item quantity on the slot when it is a stackable item. Maybe a separate item slot for each chest with its own quantity number?
so i spent a few hours making a entire inventory system then decided that was probably to complex to really explain on the answerhub and it may not really help you. so heres the basic idea you need to implement, basically if you want the items to only exist in one chest then you need to store that data separate from any other chest. i would store the info in the chest bp itself. then if you add or remove an item from the chest then it can only affect that one chest.
as for the stackable items, well from whats shown in your picture you are storing the item info as a child widget, if thats the only way your storing the info then it will be very difficult nigh impossible to stack. if you were to use another system to store the inventory info then it may be more possible. i suppose you could add in a variable in the child widget for the quantity and display that as text in that widget. without detailed knowledge of the system its hard to say exactly.
I didn’t want to leave you hanging on this one but im not sure theres much i can do to help on this one.