This is my first real attempt at an inventory system but I think I did a pretty decent job so far. I am creating this using the top down blueprint template with the starter stuff included.
I’m just going to give screen shots and a high level overview, I believe most people here should be able to figure out how to replicate my process if they want to. If anything needs expanding let me know and I can edit the post as needed.
Static Mesh
Create a basic mesh as a place holder for an item, set up collision, and enable physics
Create a blueprint from this item (BaseItem)
BaseItem
Create the following variables:
Name - Name
Bool - Stackable
Integer - Current Stack Size (1)
Integer - Max Stack Size (1)
BaseStackable
Created as a child blueprint of BaseItem
Set Stackable to true
Set Max Stack Size to 10 for testing purposes
Inventory Blueprint
Create a new blueprint -> Actor and named BaseInventory
Whenever the sphere around the inventory, which is now attached to the pawn in the pawn BP, collides with BaseItem or a child, proceed to see if the item can be collected.
This is very straight forward. If the item isn’t a stack able item it skips to checking for inventory space. This is designed to skip over items like equipment.
This part looks complicated but I hope I can explain it well. This part searches the existing inventory array to see if the incoming item name matches the name of any of the array elements AND if that element isn’t a full stack. If it cannot find an item matching the above condition, it sets the bool (has partial) to false so that when the loop ends it can bail out and jump to the next macro. If the condition is met however, it sets the bool to true, and sets the Item Slot Number integer to the array index, and bails out of the loop since we don’t need to look for more items with this condition.
Since we did find a partial stack, lets get the reference to that item by searching our inventory again for the array index that was previously set. Once we find said item, lets get its stack size and increment it +1 and destroy the incoming item since we don’t need to see if any additional spots are open in our inventory.
This is pretty basic. If the number of items in our inventory is less than the total number of items specified in the Max Inventory Size integer, then move on to the following function. If it is greater however, bail out with a simple error message.
This event graph spawns an invisible reference to the inventory actor which, using the sphere generated above, is used to detect when the player runs over a collectible item.
Please be gentle
Thanks,
Haka
PS: please disregard the attachment file for the Add Item that includes the Last Item, Get, and Set functions. They are not needed.
This is intended to be more along the lines of R.P.G. inventory like Diablo except without the whole items taking up more than 1 slot. I don’t even want to attempt that. The items that stack would be like potions or use able items and non stacking items would be like equipment.
Inventory is one of those things that I haven’t dug into so I haven’t really understood how it is handled. Just your overview, without the screenshots, goes a long way to bridge that conceptual gap. I will have to keep up with this thread for the day I begin to implement similar(vaguely) features in my Civ game. Good luck!
this is awesome, any chance we could see a video sample of what it looks like when you are playing? If not, no big deal, I will just try this out when I get home tonight
Sadly my internet speed is horrible from living way outside of town (this should change soon hopefully) so I took some screen shots. Hopefully you can infer from them what is going on.
@ - I have quite the wishlist of things I want to do with the inventory. I will flesh that list out later on this week and post back here what I want to add and start posting what I’m able to accomplish.
@Ulrich - I’m honestly just happy to be able to give back. In my UDK days I had people help me all the time with issues I had.
video is out of the question since I’m on just better than dial up connection right now. Once I get a job again and can afford to live in town I plan to make many videos to help people out. What part are you confused by?
Hi there. i got to the first event graph but I’m not sure where any of those graphs go, exactly. And it wouldn’t let me put the Inventory blueprint into the “MyCharacter” blueprint as a component (using the 3rd person template) since you said to do that to the pawn.
That’s my plan. I want to create a youtube channel or something to post my progress. I’d like anyone to be able to see how I got this stuff going. Eventually I think it would be cool to have a complete basic RPG starter kit for people to take and modify.
I would so thank you in my credits for going through the trouble. also i’m sure you’d become really popular and get a ton of views from other people so please do it before someone else does. you rock!
in the meantime is my question simple enough for you to answer in text?
OT, but I’m curious, how the [profanity here] do you use the Unreal Engine? I’m in a similar situation (out in the sticks using dialup, not just above dialup) and the way UE4 is set up, I’ve found it impossible to use.
Honestly I’m just very patient. Once I got it downloaded it was really just about watching videos on youtube (they buffer like mad for me) and picking up what I could. I also reference the UDK forums since most of the stuff I want has been done there and I try to translate from UE3 to BPs