UE5 Inventory and Item System Setup Guide and Usage Tutorials

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello world Dino Mega here in today's video I'm going to walk you through step by step setting up and using each of the main features of my inventory and item system version three the first thing we're going to do is create a brand new project and I'm going to switch over to the marketplace and add the asset to the project now a third person project doesn't come with the player controller so I'm gonna have to make one I'm going to do that you just right click and select blueprint class and then player controller and then give it a name next I'm going to open up the game mode to make sure my player controller that I just created is selected go ahead and open up the player controller and next we need to add our component to it and the component you want to add is inventory and item system player controller component this is the main driver for everything related to the system and make sure you select the one that says player controller compile and save and then go ahead and press play right away you should see the Hotbar at the bottom and if you hit I you should see the inventory toggle and at this point the core of the system is ready to go and all the interactables can be used the only thing left to do is set up the pawn for the equipment system and we'll go over that in the equipment section of this video if it doesn't work for you then I recommend pausing this video and taking a look at the list of most common setup issues found on the setup page of the documentation next let's add an item to the world that the player can pick up and to do that you first need to add an item to the data table navigate to the blueprints variables data tables folder and open up DT underscore items what you see here are all the default items used in the demo I recommend leaving them for now so you can use them as testers or as a reference for when adding your own items later to add a new item just click the add button at the top then give your row a unique and easy to type row name this row name is how we'll reference this item throughout the system and for each item you add you also need to specify all the item details such as the item type the quality the name the description the icon an explanation of what each of these fields is can be found inside the item page of the documentation let's say you want to place this loot box item somewhere in the world the player can pick up to do this we need to know the row name of it I'm just going to copy it and then switch back over to the viewport and navigate to the blueprints interactables items folder and drop a copy of the BP underscore interactable underscore item into the world then from the details panel set the item row name to the real name of the item from our data table and for me that's loot underscore box press play and you should be able to run over and pick up the item I'll show you how to add items to the player's inventory using blueprint in a minute but first let's go over a few more of the basics the storage containers give your players somewhere other than their inventory to store items and add a storage container to your level navigate to the blueprints interactables container storage chest folder and drop a copy of the BP underscore storage underscore container into your world press play and run up to interact with it you can add items to it and when you restart the game the items are still there you can also easily change the slot count by selecting the AC inventory component on the storage container and changing the slot comp variable from the details panel in this example I'm changing it to 10 slots the currency system lets your players amass wealth without consuming precious storage space you can add new currency to the system the same way you add any other item through the DT underscore items data table setting the item type to currency is how the system will know it is a currency and currency gets converted automatically from an item to the currency form by the system whenever it touches the player's inventory so to add it to your world or awarded to the player you can do so the same way you do any other item [Music] let's switch gears and dive into working with the system through blueprint I'm going to show you three examples first we're going to start off inside our player controller I'm going to make an event bound to our one key now since we attached our inventory item system to the player controller we can easily access the system just by dragging and dropping the reference from the component panel from this reference we can drag off and search for AC main this will list off the four main system components these are all instances of the AC inventory component which is our storage mechanism these four main components get added automatically by our item system they're used to store items for the Player's inventory the Hotbar bank and Equipment select the AC underscore main underscore inventory one this is for our players inventory let's add an item to it drag off and select the add inventory function there are four inputs on this ad inventory function the item real name is the real name for the item in our data table the quantity is the amount of the item we want to add to the AC underscore main underscore inventory component these two are the only required inputs the two slot ID is if you want to put it in a specific slot leaving at negative one will have the system Auto check to place it in the best slot and the override data is for our item data system and we'll go over this later in this video for now enter loot underscore box in the item row name and five in the quantity box go ahead and press play and try it out when you press one you should add five loot boxes to your inventory now for our next example let's go into the player character from here we don't have a reference to just drag and drop into our blueprint so here's how we get it first let's start off with a new event I'm going to use the 2 key for this one next right click in the graph and search for get player controller and then from that node drag off and search for a git component by class from the component by class drop down select AC underscore inventory item system now we have our reference and it works the same exact way as it did for the one that we dragged and dropped into the controller graph from it we can get our AC main underscore inventory reference and from that we can do our add inventory function this time let's give the player some cooked meat press play and give it a try now this does work but if this is the kind of thing you're going to be doing frequently I highly recommend caching this reference for steering this git component by class every time and here's how you can do that let's add on to the begin play and duplicate our get player controller and our git component by class nodes and this time we're going to drag off and select promote to variable give it a name like AC underscore inventory item system now back in our two key binding we continue to get player controller and get component by class nodes and plug in our new AC underscore inventory item system variable go ahead and press play and try it out [Music] for this last example we're going to create a new blueprint actor to place in the world that when we overlap it will give us some gold coins so go ahead and make a new blueprint and give it a name I'm going to call mine my refill point drop a copy of it into the world and open up the blueprint then add a static mesh and I'm going to use this cone mesh with a gold glow next add a sphere collision and make sure the radius of it is big enough for the player to easily walk into I'm going with 140. next select the sphere collision and create the on component begin overlap event using the details panel from the other act or pin drag off and select get instigator controller and from this one drag off and select is player controller I'm also going to hook up an is valid node to the git instigator and a branch to the is player controller and then wire everything together and once again I'm going to drag off the get instigator controller and this time select get component by class and select our AC inventory item system let's grab the AC main inventory again and then this time let's add a random amount of gold underscore coins press play and give it a try whenever we overlap the sphere Collision the actor is paying us gold coins these examples should be good starting points for you when you get some time open up the AC underscore inventory component to see all the functions and events you have access to for now let's switch back and check out some of the other features included with the system next up we have the vendor system and this is where your player can buy sell and trade items to add a vendor to your world navigate to the blueprints interactables NPCs vendor folder and drop a copy of the BP underscore MPC underscore vendor into the World Press Play and give it a try by default the vendor includes a few starter buyable items and here's how you can change and add more select the AC vendor component on the bpmpc vendor that you dropped in the world then expand the Bible items these are all the items a vendor is selling to the player for each buyable item you'll specify the item ronay for the item you want to sell the item quantity per buy is the quantity of the item real name the player receives for each purchase the available quantity star is how many of the items the vendor has for sale at the start of begin play if you set this value to negative one it will be unlimited available quantity Max is the max that can be available at this NPC if using the restock system and to use the restock system you set the auto restock over time to true the restock rate in seconds is the frequency between restocks of the item and the restock rate per item if checked will increment the available stock each restocking and if it's false each restock will fill the available quantity to the available quantity Max sale price is the amount of the cell currency you want to charge for the item you are selling to the player the sell currency can also be another item override data is for our custom item data system and we'll go over this later in the video now let's add some cooked meat to this vendor add a new item to the Bible items and set the item row name to cooked underscore meat then set the sale price on the cell currency I'm going to charge the player five gold coins for a piece of cooked meat when the player sells items to the vendor the price for each item is calculated using the sell item multiplier multiplied by the base price for the item as defined in your data table if we look at our data table cooked meat space price is 10 and we take this and multiply it by the 0.5 cell item multiplier stored on our vendor and this gets us five and since the cell currencies gold coins this is the currency we will pay the player in in most cases you're going to want to create a few different vendors that you reuse throughout your level here's how I recommend handling this first I'm going to make a copy of our cooked meat as we'll use this on our new vendor next right click on the bpnpc vendor and create a child blueprint give it a new name I'm going to call mine BP underscore NPC underscore Meet vendor I'm going to make this one red instead of green next select the AC underscore vendor component inside the blueprint and find the Bible items I'm going to trash all of them and then add a new one and then I'm just going to paste the cooked meat that's currently in my clipboard into the new Bible item place a new vendor in the world and give it a try now whenever we need to add our meat vendor we can just add it to the world from the content browser and you can repeat the step for each of your vendors the banker is another simple storage solution for your player the key difference between the storage container and the banker is that the storage container is unique to the level and its contents are available to all players where the banker is accessible across different levels and the contents are unique to the player to add a banker to your world navigate to the blueprints interactables NPC's Banker folder and drop a copy of the BP underscore MPC underscore Banker into your world press play and give it a try if you want to change the number of slots in the bank navigate to your player controller and select the AC underscore inventory item system component navigate the details panel to the player settings section and expand it now just change the value of the bank slots variable to the number of slots you want the player to have [Music] to get rid of this Gap that appears you need to open the UI underscore Banker in the ui's NPC's Banker folder then select the size box and disable the Min height constraint press play again and check it out and change the column count you need to go into the widget blueprint and update the columns variable to the number of columns you would like to use the loot system provides a variety of ways to award items to your players treat these as starting points as under the surface they all work the same way with the same set of options [Music] let's check out the treasure chest navigate to the blueprints interactables containers Treasure Chest folder and drop a copy of the BP underscore Treasure Chest into the world next take a look at the loot distribution variable on it this is how the items we award are presented to the player you have three options Loop through the UI which will show the loot window spawn loot items in the world which will spawn each item in the world using the BP underscore interactable item blueprint and finally the spawn loot items in container which can be used to drop a container holding all the lootable items now this one doesn't make much sense for a treasure chest but it does come in handy when we want to drop the player's loot or an enemy's loot the loot source is how we Define what items to award through our loot distribution we have three options for the loot Source loot table which is how you can have chance to decide what items to reward the player from a reasonable list of items inventory component or reward items found inside an inventory component on the same actor and custom loot which lets you define a list of items right here on the component for each loot Source there are also additional variables that can be used to further customize the experience for custom move we have our list of items that we want to award each item is guaranteed for the table we Define the row name of the loot table we want to use data table for the loot table we found in the blueprints variables data tables folder and each row is a list of items the chance of the item to drop and the Min and Max quantity to randomly award the quantity of the item to the player when it procs and we also have the option to add override data if we need the last option is the inventory component and we use this to drop the player's loot now the drop the player's inventory we need to First add the AC underscore looting component to our player controller then to trigger it we just call the handle event on this component whenever the player gets knocked out after adding the component make sure you set the loop distribution and loot Source settings and to handle the loot I've included a button you can use to test this it can be found in the demo map helpers World buttons folder and it's called BP underscore button underscore respawn take a look at the code inside this button to see exactly how it works and if you want to drop the player's hot bar equipment or even contents of their Bank when loot is handled we would add additional AC looting components and each one set up with unique stash index now to drop Flute from an enemy we need to First create our enemy I'm going to keep it simple and make a child of our BP underscore third person character I'm going to call this one BP underscore anime open the blueprint and add the AC underscore looting component to it then specify your loot source and distribution settings for this example I'm going to adjust the radius of the Collision then create the on component begin overlap event for the collision and for our event we tell the AC looting component to handle the loot we also need to add a copy of the AC inventory component to this actor as it's a prerequisite for using the loot system and we might also need to adjust the Collision so we can actually overlap this actor right now it looks like it's blocking and when the player overlaps the enemy the enemy will drop its loot you can also look at the BP underscore button underscore kill and the world buttons folder for another example of dropping the enemy loot from another actor and the loot boxes are actually usable items which is something we'll go over shortly one key thing to note is that there is a usable item Handler which is set up to use a loot table system this works in conjunction with the item data variable called loot underscore table and we also go over item data later in this video but to keep it simple this is how we can store additional information about our items for the loot box we can change our loot table using the value we set when we use this key loot underscore table the included crafting and recipe system is how your players can create new items from other items in your game and the crafting station is where they will create a map you can have multiple crafting stations each with a different set of recipes to add a crafting station to your world navigate to the blueprints interactables recipes tables crafting folder and drop a copy of the BP underscore recipe table underscore crafting into the world press play and go up and interact with it as you can see it's telling us we do not have access to crafting and this is because the crafting and recipe system is optional and to reduce the overhead when it's not in use we have to add the crafting and recipe system to our player open up your player controller and add a component search for crafting and select the crafting and recipe system this will add the AC underscore crafting component to your player control now when we interact with the crafting table we can see the recipes we can add another instance with a different style to the world and set the recipe table type variable to determine what recipes are shown for it for this new one let's select Forge as the recipe table type now when you interact with this red one we get a different list of recipes if you want to add or change the recipe table types you can do that by editing the E underscore recipe tables enum and the blueprints variables enums folder now to add new recipes navigate to the blueprints variables data table folder and open up the DT underscore recipes data table what you see is all the recipes currently in the system used by the demo content and if you click the add button on the toolbar you can create a new recipe go ahead and click it and select a row name here you can select the recipe table to show the recipe on as well as all the visual data like name descriptions icons the recipe seconds to make is how long it'll take to actually craft an instance of this recipe the recipe success chance is the chance that it will succeed with one being 100 and if the value is less than one the recipe can fail and if it does fail the materials will be lost the recipe bonus chance is the chance that the recipe can create extra items for each time it is crafted for example if you're making potions and you wanted to give the player a chance to produce extra potions you would set this bonus chance to a value greater than zero zero point three five for example would mean it has a 35 chance to proc a bonus and when a bonus proxy will take the quantity of the item produced through the yield and multiply it by a random amp between your recipe bonus multiplier Min and recipe bonus multiplier Max next we have the recipe ingredients and this is where you'll Define the requirements for this recipe and finally the recipe yield and this is where you define what items are produced from this person so each item produced in your yield you can specify the item row name the Min and Max quantity and any additional override data you'd like to include the starter item system provides you with an easy way to give the player items at the very start of the first play session of your game to add starter items open the player controller and select the AC inventory item system component then navigate the details panel to the player settings section and expand it in here you'll find the starter items click the add button to add an item to it the key represents the systems I'm going to select inventory now click the add button for this level for each item you want to add to the player's inventory enter the item row name quantity and any overwrite data to make debugging the starter item system easier for you I've included a reset button which can be found in the demo map helpers World buttons folder and it's called BP underscore button underscore reset player jumping on this button reset all the players inventory components as well as re-award the starter items one thing you want to keep in mind by default the equipment system equips weapons through the Hotbar if you keep this functionality and you reward a weapon as a starter item do not add it to the equipment system instead add it to the hop bar system the item data system is how we can add change remove and get unique custom data about each instance of an item in our game an item data can be as simple or as complex as you need it to be now this is an advanced feature and it's going to require multiple videos to fully explain and the details about it covered in this video is just a primer on the top so what exactly is item data let's open up our item data table and look at our loot box it has three data points each data point is a key and a value now these data points are used elsewhere in our systems changes as part of our usable item system and it's the count of how many times this item can be used before it is destroyed each time the item is used the value is decremented for our loot box we also use the loot underscore table key with the value being the item row name of our loot table the loot underscore table underscore chance we can use to set the minimum chance when the table system rolls the dice to determine our loot for equipment we can store our attributes like damage and crit chance or data about what player created the item let's take a look at dinos egg launcher one of our demo weapons we have damage crit chance clip size and crafter now take a look at the item's tool tip in our game all the text you see in green is from the item data of the item the formatting of this data is handled through the DT underscore item tooltip public data data table found in the blueprints variables data tables folder and by default data is not shown to the player to make it show you have to add your key to this data table you also provide the format of the string as it should be shown on the tooltip as well as the formatting of the value we use the word value wrapped in Brackets to represent our value in this formatted string and you can also use the letter s wrapped in Brackets to include the letter s if the value is not equal to one for example you wouldn't say one charges but instead one chart you also want to say four charge but you would say four charges and this s variable is how you handle both scenarios the value type determines how the value is shown on the tooltip default does not change anything about the value and it'll appear exactly as it appears in your data and if the item is set to percent it will take the value as a float and show it as a percentage range is how we can apply a deviation from our fixed value to represent a more Dynamic value and we use range on the damage tooltip and the range type uses the value variable field to determine the deviation amount the last field on the stable table is our value replacers and we use this to better describe a value to the player for example use the clip underscore size with a value of zero now in our weapons equipment Handler look for this key and if it's found we override the default values set in that equipment Handler we also make it so a value of 0 actually represents an unlimited clip size it does not require reloading but showing zero rounds per clip doesn't really make sense to the player and this is where our value Replacements come in for our clip size of our value equals zero we instead show the word unlimited which makes a lot more sense in the context now one thing you have to keep in mind when an item is spawned into the world with the item data that item data will persist on that item for the life of it the defaults from the item data table are only used when the item is first created so if you make changes to the item data will not fight the items that already exist it will only apply to new ones that are created from that point on as we have covered in some of the other parts of this video we often have the option to provide override data and override data is how we override the defaults when spawning an instance for example if we want to change our damage value for this one particular instance in the world we would do that from the BP underscore interactable items details panel you can also use this to add new data points that were not previously on the items you'll find this over at data variable everywhere you can add or create an item one limitation you'll want to keep in mind is if you have data like the charges variable on an item that changes from one instance to the next you do not want to make the item also stackable this will cause a data to merge and changing the data will affect all in the stack so if the data is dynamic and can change at runtime make sure it's an unstackable item as well and make an item on stackable you just set its Max stack size to one now remember this video is just a getting started guys and what I've covered to this point about the item data system is is just the basic usage of it does get a lot more advanced from here and I do have plans to cover these Advanced uses of the system and more videos in the future and we'll cover things like changing adding and removing item data at runtime and the system also has a number of tap in points for you to add additional logic at key points of the item creation transfer and rendering processes the documentation for the item data system will provide you with more information and Direction and getting started with these Advanced Data functions and the tap endpoints and the spoiling item system is also an integrated example of using the item data system and if there's a specific part of the item data system you would like for me to elaborate on in one of these future videos please let me know in the comments of this one usable item system is how we add functionality to our items for things like loot boxes and consumables the way we assign our functionality to an item is through our DT underscore items data field called item on use is how we specify the Handler to use when the item is used navigate to the blueprints components usable items folder and make a child of the AC underscore item on use this is our base blueprint for our usable item functionality I'm going to call mine AC underscore my new usable item open this new blueprint up and then override the use item event this event will provide you with the player controller that the item is used on the custom item data and the item row name of the item being used these inputs are provided to you to help you build out your functionality but they are not required one thing you'll want to keep in mind is after this event runs this blueprint will be destroyed and removed automatically so you do not want to use this to store something that you need to access later now for example let's just show a custom message on the screen we can do this using the C custom alert event on our AC underscore inventory item system component that's attached to our controller and to get this reference drag off the controller input node and do git component by class then select AC underscore inventory item system from the component class then from this pin we can call our custom alert event go ahead and enter some text and choose a color for your alert now let's head back over to the DT underscore items data table and assign this usable item functionality to one of our items I'm going to use the poison vial since it doesn't currently have a usable item Handler from the item on use field select a child blueprint we just made for me that was AC underscore my new usable item and I'm going to duplicate our BP underscore interactable item and set it to our poison vial now when we press play and pick up the vial we can use it and when we do we see our custom alert when we use the poison vial the item is automatically removed now if we want to make our item reusable where it isn't destroyed when it is used we head back over to our usable item Handler and set the is reusable item Boolean variable to true and if you don't see this variable you need to enable the show inherited variables from the gear icon menu now when we use our item it works but it's not consumed which lets us use the item again and again and we could take this a step further and set a limit on how many times this item can be reused before it is destroyed and then to do this we use the charges item data key in addition to the Boolean that we enabled for reusable items I'll head back to the item data table and add a new row to the item data set the key to charges and the value to 5. this will let us use the item five times before it is destroyed and as I mentioned in the item data chapter of this video you'll want to make sure items that use Dynamic data like the charges key where the data can change over time are also non-stackable as without it the data can merge when one stack of the item is combined with another and the subfolders in the blueprints components usable items folder will provide you with a couple different examples make sure you check them out out when you get a chance the spoilable item system is how we can set expiration dates on our items when the item expires it will be destroyed and when it's destroyed we can actually spawn another item in its place for stacks of items just one of the stack will be destroyed at a time displayable item system is actually built on top of our item data system and it's included as an example of an advanced uses of it so how exactly do we make a spoilable item let's take a look at the golden goose egg to see how it works as you can see we have three different item data keys that we can use related to the spoil system the onload key is part of our item data system this is how we tell the item data system what logic to use when the item is created we set the value of onload to spoil our item data system knows to activate the spoil system our next key is the spoil underscore time this is how we Define how many seconds this item will last before it expires these two item data keys are required to make a spoilable item and the last key spoil underscore item is an optional one that can be used to create another item when this one expires when our golden goose egg expires it will produce a gold coin let's change it to spawn raw meat when it expires the spoiler system also comes with the feature built into the AC inventory component that lets us specify the multiplier used when calculating the expiration of the item and with this we can turn our storage container into a freezer that slows down the swelling process or a rapid spoiler to speed it up and to do this just drop a copy of the container in the world then select the AC underscore inventory component on it by default the spoil speed multiplier is one and if you reduce this let's say to 0.1 this will make items stored and it spoiled 10 times slower like a freezer wall we put a piece of cooked meat that has about 460 seconds to expire in our freezer it will extend it to about 4 600 seconds and if we take it out the remaining time is readjusted to reflect our default multiplier and one thing you will need to keep in mind is if you change the multiplier while items are already in the component they will not get the updated multiplier until the next time they are added okay now let's make another container and this time let's increase the spoil speed multiplier to 10. now when we put a spoilable item in the container we'll spoiled 10 times faster and let's boost this up to 100. now spelling arms so fast as actually consuming multiple items for spoil cycle with our golden goose egg and this spoil cycle is controlled by the value of the spoiled item scan speed this value is the number of seconds between checks and by default we are tracking every five seconds if you reduce this a spell check will happen more often and there'll be less of a delay when it not expires keep in mind this delay is not really adding more time to stacks of items If an item spoils during this time Gap the time difference is automatically applied to the next item in the stack the one last thing I want to mention about spell system is that time-based logic is all driven by UTC which is how we can expire items when the player is not on and you can change this time logic to your own time system by adjusting the functions found inside the BP underscore shared functions function library and the blueprints variables folder expand the spoil system section to see the related functions the included equipment system gives you a starting point that is fully integrated into the item system and with it we can add custom functionality and it works with both modular and non-modular poems now there are a lot of moving parts to the equipment system and we'll cover most of them in this video but please keep in mind this video is not a substitute for the documentation now for the equipment system let's start off with talking about how you add equipment head on over to the blueprints variables data tables folder and open up the DT underscore equipment and DT underscore items data tables as you can see our equipment table comes with a handful of examples and for each item in our equipment data table we have a row with the same exact row name in the item data table this shared row name is important as this is the common link between the two systems now you might be wondering why we did it like this and think about it this way all the equipment can be considered an item but not all items can be considered equipment and it's because of this we only want to store equipment related information on the equipment data table and the item related information on the item data table now the fields in the item data table are pretty self-explanatory and the documentation does explain them in detail but one field you do want to make sure you set is the item type and make sure you set it to equipment now let's take a look at the fields that are included with the equipment data table our first field is the equipment slot enum which is used to decide where on our Palm we want this piece of equipment to equip to and we'll go over setting up the equipment slot on our Pawn in a little bit next we have the skeletal mesh and static mesh and whichever you use is up to you you only need to use one though and only if you want a visual for your equipment if you have no visual you can leave both of them playing keep in mind the static mesh on the item data table is used to show the item when it's dropped or spawned in the world and the one here on the equipment data table is the one that's shown when it's equipped on the pawn now they can be the same or different the choice is up to you but remember the one in the item data table is required where the one in this equipment table is not required the base transform can be used if this piece of equipment scale location or rotation needs to be adjusted on all points to adjust the transform for all equipment on a specific slot for a specific Pawn we'll handle this inside of our pond and we go over this in the setup section of our Pawn now the equipment Handler override is how we add functionality to our equipment so like our weapons or rocket boots and we'll take a closer look at the equipment handlers in the next part of this video one thing to keep in mind even if you have no visual you can still add functionality to this equipment an example of this is in demo world is the trinket that makes you smaller the equipment materials is how you can override the material for your match this field is also used when styling our mesh when rendering it in the world with our BP underscore interactable item spawning equipment in the world or giving it to your player works the same exact way as you would for any other type of item in your game it's because of this common link with shared row names that we can easily do this and if you're having problems take a look at the equipment page of the documentation it has a section covering the most common issues equipment handlers let us add functionality to our equipment and the included examples we use equipment handlers to create the weapons rocket boots and the trinket that makes you smaller we Define what equipment Handler to use for each piece of equipment through our DT underscore equipment data table using the equipment Handler override field and if you don't set any value in this field you'll use default base equipment Handler which is visual only to make a new equipment Handler create a child of the blueprint AC underscore equipment Handler in the blueprints components equipment handlers folder then open it up to build out your functionality override the following events unequipped is called at the very end of the equip process right before the pawn is notified on unequipped is called when the equipment Handler component is about to be destroyed to use this you also want to set the value of manual unequipped to true this is a variable inside the equipment Handler and then called manual unequipped which is an event when it is okay to continue with the unequipped process take a look at the lucky charm trinket for an example of this in action on primary attack is called when the equipment primary attack input button is pressed on primary tax stop is called when the primary button is released this can be used as the stopper when you want the user to hold the button into attack like an automatic weapon or a flamethrower on secondary attack it's called wind equipment secondary attack input action is pressed out and on secondary attack stop is called when it's released and this works the same way as the primary variant but it's tied to another input I do jump is called when equipment jump and put action is pressed and we use this with our rocket Boot and on do jump stop is called when equipment jump input action is released this is not currently used in the demo but this could come in handy if you want to make a jet pack that works while the jump button is held on and stops when it's released in addition to these override events there are also a number of variables that you can change these are all provided by the base Handler which is the parent blueprint used by all the other included examples check out the code inside the included examples found in the subfolders or the blueprints components equipment handlers folder these examples will give you a number of different jump off points where you can then use these to create your own child blueprints for example the dinos egg launcher and Timmy's egg launcher handlers are only changing variables that are inherited from the range weapon Handler now let's talk about how we can set up a pawn so we can actually equip our equipment on it now since every Pawn is different and your game might have multiple pawns all with unique skeletons we need a way to handle all the possibilities and the simplest solution was to manage all the data unique to the pawn right here on the pond to assist us with this we added implement the functions and events provided through a blueprint interface and using these functions and events the equipment system can communicate with our Pawn to get details like what socket and mesh to equip weapons to we also use this when the equipment system needs to tell the pawn that it did something like reloading a weapon first let's set up our Pawn to work with the equipment system and there are a number of demo equipment pieces included that we can use as our testers I'm going to first opened my Pawn for me it's the BP underscore third person character next click the class settings button on the menu but then from the interfaces section of the details panel click the add button next to implemented interface from the list select BPI underscore equipment next expand the interfaces section of your my blueprint panel to show the newly implemented functions and events now we have to create the code for each one and we're going to start off with the get equipment mesh data interface function and this is how the equipment system will get information about what socket or mesh to use on your palm for each piece of equipment it tries to equip and with each call of this function the equipment system also provides the equipment slot that it's currently trying to use equipment slot is where on the character the player is equipping the item to and for each piece of equipment we got to our game we also get to Define what equipment slot it goes into and this is done in the data table and we'll go over this in a minute and to get you started I've included a bunch of equipment slots now the return node for this function is how your Pawn will tell the equipment system details like what socket or mesh to you and depending how you plan to equip equipment in this equipment slot will determine which of the variables you end up using and here's a quick overview of each and then I'll show you how to implement them next the equipment method is how you tell the system if the item you're equipping to the equipment slot is going to attach our equipment match to another on the pawn or modular if it's going to replace the mesh the use skeletal measure variable is the mesh on our pond we want to use the attached socket name variable is used to relay what socket on our used skeletal mesh that we want to equip the equipment to attach relative offset as if you need to adjust the transform offset for all the equipment used by the slot for justice and you'll most likely use this just for adjusting the scale but you can also use it for tweaking the rotation and location relative to the attached sockets transformed the attached mirror socket name variable is if we need to duplicate our visual onto another socket on the same skeletal mesh and this can be used for things like boots gloves or arm guards attachment scale is used when using the attachment socket and this is mostly used to flip the orientation of the mesh and I'll show you this using the rocket boots example in a minute the attached theater pose component is used in conjunction with the variable that must be activated inside the equipment Handler for the equipment with this variable we can tell our equipment mesh what mesh to follow for animation the last return is modular default skeletal mesh and this is used when we're using a modular character to tell our equipment system what the default mesh should be when the item is unequipped now let me show you how I recommend setting up this function first we decide what slot machine to work with and I'm going to equip weapons first which we'll Equip to our main hand slot let's drag from the equipment method pin and create a select node then hook the slot from the input of our function into the wildcard index on the select node this will give us the option to specify the equipment method for each of our equipment slots I then recommend collapsing this node just to keep our main function nice and clean and you can double click on the collapse graph to access it now since we're working with our weapon and we have our weapons equipped to the main hand slot we need to set the value of our main hand to attachment you can use the breadcrumb to back out of this collapse graph and return to the function now since we are using a non-modular character we only have one mess and we just need to attach this one mesh to the U skeletal mesh pin next up we have the attached socket name and you guessed it drag off and create another select node hook it up to the slot from our input on the function into the index wildcard on the select node then collapse the select node into the graph now we need to specify what socket on our skeletal mesh we want to equip weapons in our main hand slot too so select your mesh on the components panel at the top left then on the details panel click the folder with the magnifying glass to navigate to the skeletal mesh assets location then open the skeletal mesh now you have to navigate the skeleton tree and look for the hand underscore arm right click on it and select add socket now what I like to do at this point is add a preview mesh which is also an option for my right click menu and for this mesh I'm going to use the dinos egg launcher then I'm just going to reposition and rotate the socket until it looks good in the Pawn's hand when you're ready to return to the function and set the main hand socket name to the name of the socket you just created for me that was hand underscore R socket now press play and try to equip downloads anymore remember weapons do equip as a hot bar make sure you select it on your Hopper after you equipped it by pressing the key binding or using the mouse wheel to select the Hop bar slot now we won't see the equip animation just yet but we can use the weapon and it is equipped to the right location so let's move on to the helmet first I'm going to set the equipment method to attachment next I'm going to switch back over to the skeleton and find the head bone then I'll add a new socket to it for this preview asset I'm going to use the space helmet since the smiley helmet does some rotation on the face within the material and as we can see the space helmet we need to reposition and rotate our socket go ahead and position it as you need and for the included helmets we have our Pivot Point at the top of the helmet for yours you may have it at the bottom or the middle it doesn't really matter where the pivot point is but you should make sure they are consistent with all your meshes for this equipment slot I'll return to the function when you're ready and set the socket name for the head equipment to the slot that you just created for me that was head socket then go ahead and add the space helmet or Smiley helmet to your world just like we do with all the other items and press play pick it up and try it on next I'll show you how slot mirroring works and this time we're going to equip our rocket boots to our feet so that's the equipment method to attachment again then add the socket to your foot R of your skeleton it looks like mine already has a socket and I'm going to use the engines provided color calibrator mesh as a demo and it looks ridiculous but it looks like the position is fine now back to our function we set the socket name for our feet equipment slot and for me that was foot underscore r underscore socket go ahead and place a copy of the rocket boots in your world press play pick them up and try them on as you can see they do work but they're only equipped to one foot and this is where our mirroring into action go ahead and return to the function and drag off from our attachment socket name and create the select node again hook the slide up from our input of the function into the wildcard index of the select node then collapse the graph and give it a name bounce back over to your skeleton and add a socket to the foot elbow for me the foot underscore L underscore socket was already there so I'm just going to use that set this socket name back in our function for the attach meter socket name for our feet equipment slot now let me press play we can see it on both feet but if you look closely the position of the Chrome sphere is in the same location on both feet but really our mirror should be flipped so it is on the outside just like it is on our original foot and we can use the attachment scale return variable on our function to flip it over create another one of our collapse select nodes just like we did for all the others then for the feet slot set the Y value to the vector negative one and if we try it out now we can see it is now properly flipping or meshing around and configuring this function as all takes to set up equipment for use on your Pawn you just have to go through and complete the process for each of your slots as you see we didn't need to use all the variables and more information about the ones we didn't use can be found in the documentation animation montage is another thing that is unique to our Pawn skeleton so we play these from our pump and I know when we play them and which one to play we use the unequipped event which is an event implemented by our blueprint interface whenever our equipment system does something like equipped unequip reload or even swing our melee weapons it will call this event the inputs on this event include the equipment event you know which is how you can determine what action just happened if you hook a switch up to this you can see all the different events your opponent will be told about the change equipment stance is something that is only sent when the equipment event is stance change and we'll go over this variable more in the next section of this video the equivalent Handler component is equipment Handler responsible for the equipment event from this reference you can get variables like the item row name custom item data the slot it was equipped to and what I want to do is plan animation when our player equips a weapon and from the equip branch of the switch plug in a play Montage node set our in skeletal mesh component into our mesh then select the equip Montage now keep in mind the included montage is by default will only work with the mannequin if you want to use them with your character you're going to need to retarget them which is not something we're going to talk about in this video now when you press play it doesn't look like it's working but it actually is and the reason we don't see it is because it included montages are set to play on an upper body slot in our animation BP and we still need to set our animation BP to play from the slot and to do this just select your mesh then navigate to the animations location and since we're using Quinn we actually need to open up the one for Manny as Quinn is just a child of Manny navigate to the animation graph and save a cache pose of your main State then drop a reference of this cash pose back into the graph and connect it to the default slot node duplicate both his cache reference and this default slot node and then select the default slot node and change it to upper body instead connect the original output to a layer blend per bone then connect from our upper slot to the other pin on the layer blend per bone then hook the layer blender bone into the output pose next let's select the layer blend per bone and from the details panel add an item to the branch filters of the layer setup another bone name for the first spine bone on your skeleton for the default Pawn this is spine underscore zero one then set the blend depth to three press play and you should see the equip animation play right away okay and this is because right now we are telling it to play the animation whenever we equipped anything and that includes our helmet and our rocket boots which are being equipped on the begin play since we have them equipped from our last session we only really want to play this animation when we're equipping something from our main hand so let's modify our event to account for this and from the equipment Handler component reference drag off and select get equipment slot then from this drag off and select equal enum select the main hand and then from the equal node hook it up to a branch that you place between the switch and the play Montage now we will only play our equip Montage when we equip a weapon now let's go ahead and expand on this for some of our other events so I'm going to drag off from the Montage to play node and create a select node I'm then going to hook our equipment event enum into the wildcard Index this way I can play a different Montage for the different equip events involving our weapon let's do the unequipped Montage next and this one is actually just our equip Montage being played backwards and to play a montage backwards we need to start at the end and make our play rate negative now I recommend hooking a select float node up to the play rate and the starting positions then for the pick a pin on both I'm going to hook up equip event to another equal enum node and then select unequip that way if it is an unequiv event we'll select the value in a for both of our select floats for play rate we want to set it to negative one if it's an unequip and one if it's not and for starting position we want to set it to one if it is an unequip event and zero if it's not the last thing we need to do is root our unequip event from the switch into the same one that's executing our play Montage right now for our equip event press play and try it out when you pull out the weapon it plays the animation forward and you put the weapon away by pressing the button again it plays it backwards let's hook up reload next connect the reload execution pin to our play Montage path and then just set the Montage to our reload Montage use Timmy's egg launcher to test it and when you press the left click for the first time it'll play the reload animation next up we have our melee swings go ahead and add the bat ax to your world then return to our on equipment event then connect immediately attack pins just like we did for the others the primary is activated when we use our left click and the secondary is when we use our right click Now set these montages to play on our select node and if you want to play different swings for different types of melee weapons you could create additional events on the enum and then call those instead from the equipment handlers now before we continue one thing I notice is our bad ax and Timmy's egg launcher are rotated in the wrong way because it's an issue for multiple weapons I'm going to fix it by modifying the socket and a little rotation is all we needed now keep in mind this is just a starting point the idea is to give you the flexibility to expand on it as you see fit your needs now your Pawn is most likely going to hold a rifle differently than they would when they're unarmed so how do we handle this with our equipment system well we do this using our equipment handlers on each Handler we can specify the stand outside that piece of equipment influences using the change stance 2 enumeration variable and this enome can be found in the blueprints variables enums holder so how does this work oh whenever we equipped or any cut up a piece of gear our equipment system will iterate through all of our equipment and make a tally of the values of all our non-null change stays two variables from all of your equipment handlers and whichever entirely has the highest count is the one of the equipment system and then tell your Ponder use and we tell our Pawn which one to use using the on equipment event now keep in mind this change equipment stance value is only set when we do the equip event for stance chain let's promote the change equipment stance to a variable inside our Pawn now I'm only going to update it if it's actually different than the current value then hook it up to our switch I'm going to take this opportunity to collapse both the unique portions of the sun equipment event just to clean things up a little bit the next part is our get equipment stands functional and this one is super easy just plug the variable that we created into the current equipment stance output node then set your default stance and that's it now whenever we want to get our Pawn stance we can just get a reference to our pawn and get these values using this function and this is as far as equipment system's involvement with stance changes go the next part you are going to need your own animation assets and also keep in mind there's more than one way to handle this and for my example of stance changing I'm just going to Simply change our pawns blend space but before we can set this setup we have to get our current stands from our Pawn we do this from the event graph of the animation blueprint we already have a reference to our character so we can use this and just call our get equipment stance function then we just save our stance to a variable inside our animation blueprint open our ground movement State machine section of our animation blueprint we use the value of this stance variable along with a select node and each value of the select node is a different blend space for each particular weapon type and that's it our Pawn will now change our blend space based on its current equipment stance which is set and calculated through the equipment systems equipment handlers each time we equip or unequip a piece secure that concludes the getting started guide for all the systems included with version 3 of my inventory and item blueprint system for Unreal Engine 5. I hope this helps and you can learn even more about each of these systems using the documentation and if you have any questions or would like to see a more elaborate explanation or tutorial for any part of the system please let me know I also have a Discord server now to help support these assets and I'm assuming my personal invitation to you to join us I'll leave a link to it in the description of this video as well as a link to the documentation thanks again for supporting this project and good luck with your game
Info
Channel: Dynomega (Unreal)
Views: 5,552
Rating: undefined out of 5
Keywords: ue5, unreal engine, blueprint system
Id: n2SRNuhtYcc
Channel Id: undefined
Length: 44min 42sec (2682 seconds)
Published: Wed Jul 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.