This provides a re-usable inventory system in form of a Component that can be attached to actors like players or chests in the level.
The inventory uses a grid, like those found in the Resident Evil series, to store items. If there is not enough space to pick up an item, it cannot be added to the inventory.
- Just drag the inventory zip from the releases part of the repo into your project
- The demo is to show you how it would work in game build
- You must set up your input action you want to pull up your inventory up then you set up your player and put the BP_InventoryComponent on the player
- You must create a child blueprint of BP_items to create your own and you need to override Get Default Item Object Function and after you make a child you can duplicate the blueprint and just change the dimensions, the icons, and the item class of the item you just made
-
For the inventory grid size, it is on the player under BP_InventoryComponent
-
Add/make your own icons you will need a normal and a rotated icon
-
You will need your own assets for the items you change on the child blueprints
-
If you are using your own character you need make SpawnItemFromDrop function
-
change the casts that are below if you are using your own character
- the item class isn't the actor that is placed in the world the children the item class is what is placed in the world
- The Item class holds all the code for the children
- The BP_InventoryComponent has some of the code the item and Inventory
- RoomAvailble function the way it works is it is looking for room that is available
- TryAddItem function the that works is it uses the RoomAvailble function to see if there is room if the is room it uses the AddItem
- AddItemfunction witch it adds the item to the top left of inventory and if there is no room to add it won’t add it inventory
- WBP_InvGrid Has some code for Inventory
- The Paint function paints all the lines and the icons and the colored backgrounds
- OnDrop function when you drop the item from your Inventory the item should spawn on the floor
- Create line function is the math for the lines of the Inventory grid
- GetItem function get the items you picked up and put it in your Inventory
- IsRoomForItem function checks if there is enough room for the item trying to go in your Inventory
- OnDragOver function is when you drag the item over Inventory
- MousePosInInv function it tracks your mouse in the Inventory
- OnPreviewKeyDown function when you press the R button it rotates your item icons 90 degrees
- ItemObject
- GetDimensions function it gets Dimensions of the item
- GetIcon function get the item icon
- GetItem function it gets the item
Reids channel https://youtu.be/4CjpBoKl6s8 I used it as a base so the code is similar but from here on out i am going to update, change it and i have plans to add on to it
- work for multi-player compatibility
- work for ai
There will be more to add and if you have suggestions please email Here is my email if you have questions or suggestions [email protected]