Creating a SLOT SPECIFIC INVENTORY!!

Hello Everyone,

I have been trying to make this inventory for over two weeks now and want to give up but im dying to get past this stage so I can move on to better aspects of my game.

What I am trying to make is an inventory where I:

  • Walk to an Item and press a button to pick it up
  • The item adds to my inventory
  • The Item changes an Icon on my widget to show it is now active
  • When I click that newly active button it will attach an item to the socket
  • When i click a different button that is active it will swap the previos actor placed to the new one

SO let me be specific. I have 4 types of items (Hats, Eyes, Mouths, and Shirts). These Items have 4 different Tabs that the player can select through and click the desired style of Hat, Eyes, Mouths, or Shirts.

Essentially it is similar to how World of Warcraft has their Transmogrification system. The player clicks the active button and gets that item added to the character. If they want a different Hat they click the next one and it then replaces the current one.

My issue is that system. Everything I look up about inventory systems in UE4 always has a “next slot available” system. I have specific buttons I want to be changed as the rest will have blacked silhouettes until the player picks up that item.

I have tried so many ways to get this and nothing has worked.
I have a working pick up system that uses a line Trace

234034-itempickup.jpg

This is what I have my inventory widget looking like and how it has tabs and how it looks when something is picked up. The blacked out item is how it looks when nothing has been picked up for that slot. At the moment I have it just reading the inventory and if the String (Name) is equal to the name i typed then it changes the style. It works and im happy buuuuuuutttttttttt…

I cant get anything to spawn and attach to the character socket when a specific button is pressed.
Every tutorial I have watched has a button widget that fills the “inventory vertical box.” I dont want that. I want to have the buttons placed like I have and say “if you press the tophat button and its active, spawn the tophat on the head socket and if you want to take that off press again.” or “if you want to switch this hat for another, press the active button hat you want and it switches them.”

So far its taken way too long to get this myself and as a 3D Environment Artist, I am surprised I have gotten this far.
I have also placed below a picture of my Base Item BP with the tags for name, and such.

This inventory isnt really an inventory, its rather a collection system for your character to wear. A WARDROBE one might say.

I Hope this is clear enough for anyone to help me. I know this is a lot to ask but Im so confused on how to get this to work.

Hey, so I am a bit confused on which part of this complex system isn’t working. Is it just the spawning that’s the problem or getting inventory items to be located at specific buttons? Like is the pick up system working exactly how you want? When a top hat is collected it makes button 3 available when a shirt is collected that goes to button 1 etc? Like the buttons are static which is what you want and the issue is that you can’t “spawn” the actor after pressing the appropriate button? Or are you having trouble getting the inventory to add a top hat to say slot 3 if slot 1 and 2 haven’t been filled?

I have the button changing already for when the item is picked up. The issue is having it spawn an actor that attaches to my character.
When the actor attaches such as the tophat, and you click say - the sombrero, itll switch them. its like a wardrobe. you can change outfits but keep the items. I cant figure out how to get the button actor to attach and then switch.
and say you don’t want to have the hat, if you click the tophat again it will remove it to nothing…

This is Marc by the way lol

I think I get it, and I can probably figure out a way to get that functionality for you but might not get back to you till tomorrow or so.

anything helps. been trying to get this working for weeks lol I appreciate anything you can provide. Also just so you know. each Item blueprint has info like: Text, Thumbnail, Class, and what not. if any of that helps at all

I made an inventory and I showcase its functionality here. It is very crude but you can get the idea. If this is what you are looking for let me know and I can try and figure out a way to show you how I did it.

Yes that is what im looking for! if you could so kindly help me get that I would really appreciate it!

Hey sorry for the late response.
Not sure if you tried but clicking the button once when the i open the inventory works but when i close the inventory and then reopen it and click, it adds a second item to the socket.

I know you made an inventory that is always open but ideally it would be nice to have it open on an input. sorry if this sounds picky…

Not at all, that’s an easy thing to do. I thought I demonstrated in the video but maybe not. My inventory actually opened and closed with a keyboard input. I can show you how to do that in a little bit. Also not sure why it adds 2 items…it should delete the previous one. Post your code and I’ll take a look

So these are some of the blueprints i have.
I set them up to be like yours almost to the nail ( i have a few details i added myself.)
Also not sure why but when the update buttons is called it isnt reading the item i pick up. it gives me this error "Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item2 from function: ‘UpdateButtons’ from node: Set Is Enabled in graph: UpdateButtons in object: UI_Inventory with description: Accessed None trying to read property CallFunc_Array_Get_Item2"

I have the print strings for debugging but they seem to work so not sure why when the inventory closes and i click a button, instead of destroying the item or replacing it, it addes another. Its like when the inventory closes it forgets my last inventory int or something

So just looking at the first image I can see why you get a second object, you keep creating the widget over and over each time you “open” the widget. So instead of “creating” the widget just toggle the visibility.

Here is how I did it

Let me know if anything is confusing.

So I am thinking the error is occurring because as I said in the other comment, you are using “Create Widget” each time you open the inventory. So what is happening is you are actually making a new widget each time you “open” the inventory and trying to remove the same “created” widget off the TRUE pathway but you are mixing execution pathways as I show below, this is almost guaranteed to cause errors because you are using an object reference from one pathway as the input object in a separate pathway. Only one of these pathways execute at a time thus you will ALWAYS get an error anytime the “TRUE” pathway is executed as it is dependent on getting a reference from the “FALSE” pathway which was NOT executed. So it will always be null/void and you will get the error you are experiencing.

AWESOME! that worked. Now the last issue im having is that error message: "Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item2 from function: ‘UpdateButtons’ from node: Set Is Enabled in graph: UpdateButtons in object: UI_Inventory with description: Accessed None trying to read property CallFunc_Array_Get_Item2"

This appears once i pick up and item and inside the update function. not sure if it cant understand the item index or something…

Did you change your script to toggle visibility of the widget when you open/ close it instead of creating a new widget? You should create the widget once in begin play or something and save the output as a reference variable. Then when you call “input action inventory” have that set visibility to visible or hidden for the reference widget. That should clear up errors about not finding the right objects for the update button function.

Post screen shots of how you add your items to the array part of it I think is cut off in the snow pics. You have some extra stuff in your code that I didn’t have and something in there may be causing the error. Can you post updated pics and show also the item BP itself and how it communicates with the widget to let it know it got picked up?

as soon as i get home ill post images of the item BP. I appreciate all the help

Haha no problem man glad to be of help

I am still not clear if you changed the script from creating multiple widgets first. That is why I wanted to see the screen shots of the code like you had before. You gave me like 5 pics in your other post, I wanted to see those again with your new set-up and this item thing.

Okay so i made a new intractable and just put the same code you got. The other code i had was for highlighting the best intractable i was looking at. Anyways, Im confused how the update function is working if it isnt being called in the UI blueprint. I didnt see it connected anywhere in your video. I know the actor blueprint is sending an event response into it but does that activate it? Heres the item blueprint I have and the update blueprint is the same as yours in the video yet i still get an issue when i interact with the item… It says the issue is with the SET ENABLE in the update button. I have the widget button i placed set as enable but in the graph it changes to not enabled like you setup. so not sure what the error is trying to say