How to Create Equipment Video
How Equipment Items Work
All pieces of equipment are considered items but not all items are considered equipment.
It is because of this simple fact that we don’t want to just stuff equipment specific data into our items data table, or vice versa. Instead we use two different data tables, one for the item information DT_Items, and the other for equipment information DT_Equipment. We associate our equipment to our item by making the row names match each other. Both of these data tables can be found in the Blueprints/Variables/DataTables/ folder.
So for every item in our DT_Equipment data table there is a matching row with the same exact row name in the DT_Items table.
The row in the DT_Items data table is how our equipment exists in our world when it is not being shown or used by our character. When you see it on the UI this is the item form of it. Such as when it is stored in our inventory or a storage container, or for sale on a vendor, loot in a chest, or the result of a crafting recipe.
When we attempt to equip or use our equipment is when the data from the DT_Equipment data table is used. Anything related to and including the mesh being used on our pawn when we equip something is found in this table.
For example you won’t find weapon names inside of the DT_Equipment because the weapon name does not matter when it is in the Equipment side of the system. Weapon name is something that is only visible when it is in the Item form, like when we hover over it in our inventory to see the item info tooltip. You will find EquipmentSlot in there, because every piece of equipment has an equipment slot, but not every item will have one, so our equipment data table is a more appropriate place for it.
Prerequisites
As mentioned above, a piece of equipment is an extension of an item and if you haven’t done so already, take a minute and create your item. Make sure it spawns properly in your world and that you can pick it up.
You will also need to make sure you set up your equipment slot and specialty slot if you are not using one of the included ones.
If you are attaching equipment using a mesh make sure the pivot point on your mesh is in the right location. This is the point on the mesh that will be used to attach your mesh to your pawn’s socket. If you need to change the pivot point you can do so in the editor using the modeling tools.
Create your equipment definition
- Open the DT_Equipment data table in the Blueprints/Variables/DataTables folder.
- Add a new row to the data table, make sure your row name matches the row name of your item. As mentioned above, this shared row name is how we link the item to the equipment.
- Fill out the remainder of the fields using the variables, see below for a breakdown of the purpose of each variable.
Pop quiz Timmy! To add a new piece of equipment to our game, which data table do we need to use, DT_Items or DT_Equipment?
While the statement is true, that is not the correct answer. The answer is both! This is why we see the same row name in both data tables for our demo content. The one in DT_Items is used for all of our item information, and the one in DT_Equipment is for all the equipment specific information like the visual and functionality that is added to our pawn.
The correct answer was both. This is why we see the same row names in both data tables in the demo content. The one in DT_Items is used for all of our item information, and the one in DT_Equipment is for all the equipment specific information like the visual and functionality that is added to our pawn.
That is correct! Good job, you really know your stuff. Let's continue.
Not quite Timmy! It is actually both. You might want to read over this section again before continuing.
Pawn Setup
If you haven’t done so already you will want to set up equipment on your pawn. If you have already finished this then you should be able to equip your equipment item now and see it on your pawn.
If you can’t equip your item because you haven’t created the slot for your equipment window, see the equipment slot chapter to finish setting up the specialty slot and associating the specialty slot with your player profile.
A note about Custom Blueprints
Equipment handlers are great and can handle most of our needs, but if you need to take it a step further you can leverage the system to easily equip your own custom blueprints. You can define your blueprint on the DT_Equipment data table using the EquipOther variable.
You will want to implement the BPI_EquipmentBluperint blueprint interface into your custom blueprint. This will provide an event called equipmentReady that will be called when the handler is finished setting up. This event call will provide your blueprint with a reference to the handler, from which you can get all the data you need about the equipment, item, or player. Use this event as your “begin play” / “on equip” event. There is also unequipBlueprintEquipment which is called during unequipping, and hideBlueprintEquipment which will be called when a request to hide the mesh has been received (the hide or show state is provided as an input on this event).
If you are using a custom blueprint in a multiplayer game it is your responsibility to make sure you properly set it up for replication. If you are new to multiplayer replication I highly recommend reading through the Multiplayer Compendium by Cedric Neukirchen.
A note about Custom Widgets
If you are creating a custom widget you should also implement the BPI_EquipmentBluperint into the widget, then use the equipmentReady event to get a reference to the equipment handler. The other included events will not be called on your custom widget.