Unreal Engine Inventory Tutorial: Storage System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this tutorial in this tutorial i want to show you how you can optimize your inventory so when you put the item on the same position it will just stay there and you can also swap the items and the second thing is a storage system where you can store the items in the chest for example so let's go so the first thing we have to change are the inventory itself so let's go here and add up a text so that we see the difference between the inventories let's put this right here [Music] like that and we just call this inventory like that put in the middle here of course we have to put down the grid a little bit so let's add up this to 20 and this to 70 for example great so now we need the grid for the storage so let's just copy and paste this over here as well we copy and paste the text up here and then we just make this a variable and call this storage text be sure that you set the visibility to hidden and then we go to the grid so the second grid here and as well we will call this grid storage and the size box will be the storage box and this is also a variable and as well we will set the visibility to hidden great let's go to the graph so we have to add up some new variables here first of all let's change this select item to select item index to the drop item index then we create a select item of course this is an item structure as well as an drop item the next one is select array storage s and boolean and the second one is drop array storage for this we have to go to our item slot as well because this gets a new variable as well called storage as well as in boolean let's go back to our inventory because we want to change some functions here let's start up with the create inventory let's make this more modular so we put in more inputs here the first one is the grid itself this will be in grid panel object reference and the second one is storage assen boolean so what we can do now is we go and delete the grid here then we want to connect the grid with the target of course in both cases then we go from the return value here and say set storage and just connect the storage boolean with this boolean here and the second one is we want to set the index when we create the grid and we just connect the index of course with the index so this is our new create inventory function here let's do this as well for the update inventory so what we want to do here is as well we want to create more inputs first one is the inventory itself this will be an item structure as an array of course the second one is the grid itself again a grid panel object reference essence single variable great so we can delete the get game instance as well as inventory here as well we can delete the set index here like that and then we just connect the inventory of course with the get with the length can delete the grid as well here and connect the grid with the target down here and connect the function so that's our new create inventory and update inventory function it's now more modular now let's open up our move item function i will delete everything here because we have to rewrite this completely new and now let's fix up some functions first of all let's go to the on drop function here and just connect the inventory with the update inventory function like that the second one is we go to the level here and as you can see the items has to repair as well so let's go to the item clause and as you can see we have the append item function where we have to connect the inventory of course as well as the grid so let's go from the widget here and say get grid and connect it as well we go to the add item function as you can see again we go from the inventory connected get the grid connect this as well compound save this so now the items are fixed as you can see and when you hit play you can see what else we have to fix so as well the item slot so let's go to the item slot as well when we compile it say okay we have to fix the event graph here as you can see so when we want to use the item for this let's make it a little bit different we take out our storage boolean here need a branch to ask and on false of course we want to continue so that means we can only use items in our inventory not in the storage as well we have to connect the inventory here with the inventory and go from the widget again get the grid and connect the grid as well close this go back to our level here when we hit play you can see we have to fix the third person character as well so let's open up our third person character and we have the open inventory function where we have to update inventory function as well so first of all let's go up to the begin play you can see we have changed the create inventory so let's leave the storage to false of course but but we go from the return value here and say get grid and connect the grid of course as well up here then we have to fix the open inventory function for this let's take out the input action up here and i want that this is an add custom event for open inventory so the good part about this is we can open the inventory separately with the custom event so one press of course we have to call the open inventory function and now we have to fix this part here so let's take this out a little bit here we want to [Music] get the game instance then on defaults case down here we want to cast to my instance get the inventory and then we just connect the inventory up here from the widget we get the grid again connect this as well like that compile and save this so now we fixed all functions so let's create the storage i created a new folder for this so we go right click blueprint loss actor and this will be the storage underscore class let's open this up the storage class gets some static mesh of course up here as well as some box collision and a few variables so the first one will be the storage the storage is of course an item structure array and the second one is the name the name is justin text us on single variable like that so let's go to the event graph and we need the class settings of course and we want to add up the interact interface so that we can interact with the storage it's called the interact event here get the player character then we want to cast to the third person character like that we get the storage here get the length of the storage we want to get the widget and then we get the grid storage we want to get the storage box so the size box and of course we want to get the storage text so the name of the storage so we go from the widget here we want to of course create the inventory sorry storage grid here connect the links with the slots we connect the grid storage with the grid here and check the storage boolean to true second one of course is we want to update the inventory we again connect the grid and the storage of course like that and then we want to set the text like that we take out the name and just connect it with the text we go from the storage box and want to set the visibility of course to visible we connect the storage text as well like that and then we have to go back to our inventory because we need one more variable and this will be the storage itself we choose our storage class object reference like that go back to the storage class of course and then we go from the widget here and want to set the storage like that and of course this is a reference to self and the last part is we go from the third person character and want to open the inventory so our custom event so this is how we interact with the storage one last thing we go to the box collision here and want to call the end overlap event we want to cost to our third person character we get the widget again get the storage box as well as the storage text and want to set the visibility for both of these of course to hidden like that then we go again from the third person character get inventory open saudi boolean to check if the inventory is open check with the branch if it's open then of course we call the open inventory function again so that we can close the inventory in this case great compile and save this so now we can create a chest so let's open up the storage here and add up some elements so that we can store some more things let's add up 24 elements for example compound save this now we go to our level here we have this chest and we go right click create child rupen and this will be our chest now we can open this up and then we just set the static mesh here of course so let's find this in the content browser here it is select it put it right here then we set up the box collision more in front of this go to the chest itself we have the storage of 24 elements and the name will be just chest compound save this and now we just have to place this here in the world so let's go to our storage chest here right click on this static mesh replace selected actor with and you can see the box collision right here so let's see if this works we hit play pick up some items you can see them in the inventory here we go to the chest press e there's the storage chest with 24 item slots so the next step is we want to move the items from the inventory into the chest and from the chest into the inventory as i said we need to complete new move item function so let's go back to our inventory here and open up our move item function here go to the details we need few more inputs here so the first one will be so deselect array this will be an item structure array the second one is the drop array and the last one is move between assen boolean single variable like that so we take out our select item index and the drop item index first of all we get a copy of the select item index so in the select array as well as the drop array like that the second thing is we want to check if the select item index and the drop item index are equal to each other like that and again we go from the select array get a copy again say split structure pin connect the select item index of course again copy and paste this down here as well for the drop array and the drop item index down here so first of all we want to set the select item and the drop item so of course the select item is the select item index here and the drop item index is the drop item like that so the first condition is we ask are we moving between the storage and the inventory so this will be the first condition on the false case we need another branch to ask is the select item index in the drop item index equal to each other after this we need another branch on defaults case we continue as well on the true case up here like that then we want to check is the drop item valid so we check are we moving between something then is the select item in the drop item index equal to each other and is the drop item index valid so that means there is already an item on this place for this we need another branch on the true case up here we will check are the names equal to each other so is this the same item so it is the select item and the drop item equal so we compare the name to each other here like this and this is the condition up here then we go from the drop array and want to set array element let's copy and paste this so this is the true case right here we say right click split structure pin on the first one so the drop array element and then we just have to connect all these pins so of course the drop index is the index here the name is the item name the amount is the integer plus integer because we stack something so we have to connect the amounts of the select array and drop array this will be of course the new amount then we connect the thumbnail the mesh the actor [Music] the state the time usable and the valid like that the second one here is the select array of course with the select item index and we leave everything like that so this is the first case when we want to stack something in our inventory or the storage so we copy paste this down here like this this is the false case of course again we connect the drop array first and the drop index as well as the select array and the select index like that then we do the opposite we because this is the swap item function so the select item goes into the item here first and the drop item goes into the second one so we want to swap the items this is for stacking the items and this is for swapping the items and the third situation is we just want to move the item so again we copy and paste this down here this is the false case here again we take the drop array connected and the drop index as well as the select item goes into the item here the select array goes into the second one here the select item index of course to the index and we leave it to nothing because we dropped the item to the new position so this is for again stacking then for swapping and for just moving the item so now we need another function to set up these arrays here let's say set arrays we get the game instance because to my instance in this case get the storage here get the inventory from the storage we get the storage array like that we want to get the grid as well as well as the storage grid or the grid storage as well as the select array storage to the boolean as well as the drop array storage like that the first branch will ask so is the select array a storage system then we need two more branches up here for the true case and defaults case this is the case down here so it is the drop array the storage and the same question up here is the drop array storage then we take out our remove item function this is the true case we do this four times here like this so defaults case up here the true case down here defaults case down here as well we need the update inventory function up here as well two times here like that same thing here and one time down here so now we have to connect everything i try to explain this as good as i can so first case is the select array is in storage and as well the drop array is a storage so we want to move something inside the storage so that means we connect the storage with the select array as well as the drop array of course as well we want to update the inventory so we want to update the storage grid first case second case is the select array is true so it is a storage and the drop array is false so we want to move something from the storage to our inventory so this select array is of course the storage and the inventory is the drop array we want to check the move between because we move from the storage to the inventory and we have to update both inventories so we connect the inventory with the first update inventory as well as the grid and we do this up here sorry storage inventory and the storage grid like that second case the third case is the select array storage is false so that means we take something from our inventory and the drop array storage is true so we take something from our inventory to the storage so let's go for it select is the inventory and drop is the storage we want to move between something and as well we want to update as i said the inventory as well as the storage and the last case is the select array storage is false so this is the inventory and the drop array storage is also false so we want to move something inside our inventory so we take out our inventory as a select array as well as the drop array and just want to update our inventory with the normal grid so this is the hall function i hope you understand it so we have to change one last thing we have to go to our item slot as you can see we have the on drop function and we have to replace the move item with the set erase function and we go to the on drag detected and have to set the select storage to the storage boolean here as well as the on drop we have to set the drop array storage boolean to the storage here like that great let's see if this works we hit play pick up some items here so i can move the items here we can swap the items if you want to we go to the storage here open this up we can place something in the storage as well we can swap this in the chest as well we can move it wherever we want great so i hope you enjoyed the tutorial if you have any questions please let me know and yeah goodbye
Info
Channel: Seredias
Views: 3,561
Rating: undefined out of 5
Keywords:
Id: w8JvklT8Sxo
Channel Id: undefined
Length: 26min 29sec (1589 seconds)
Published: Sat Jun 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.