Equipment / Pawn Setup

Equipment Pawn Setup Video

Equipment Pawn Setup
Equipment Pawn Setup — 15:07

Pawn Setup Prerequisites

In order to equip equipment on our pawn we need to configure the pawn to communicate with the equipment system. This chapter covers the setup on the pawn but before you do this, you need to first make sure the equipment slot you are using is set up. Confirm that you can equip your equipment item to this slot through the UI before continuing.

How it Works

Every game is different, and at the center of every game is your player’s character. You might have multiple unique characters or just one. Each might also have its own set of animations, skeletal sockets, and relative transforms. We needed to come up with a solution to handle supporting all of them while still keeping it easy to use. We accomplish this by using a set of blueprint interfaced functions and events.

Each of your unique pawns who will be using this equipment system will require integration of this BPI_EquipmentPawn blueprint interfaced functions and events.

These interfaced functions and events can be as simple or as complex as you need them to be but keep in mind the purpose of them is to provide the equipment system with the information it needs to know about your pawn. We also use them as a way for the equipment system to let your pawn know when certain events are handled (like when you equip, unequip, reload, and change stances) so you can play the appropriate animations for that pawn.

Before you setup your own you should first take a look at how these functions are handled inside the Demo Character found in the Demo/ folder.

BPI Functions

The following functions are provided with this BPI_EquipmentPawn blueprint interface:

getEquipTarget Used to get information about the equipment slot on the pawn, such as if it is a modular piece of equipment, the mesh, socket, and any pawn specific relative transform offsets, provides the equipment slot and equipment slot index as an input. This is the main workhorse for getting equipment to show up on your pawn in the right location. The index can optionally be used to offer different returned data. For example you may equip main hand equipment to your right hand and a specific piece of equipment should be equipped to the left hand instead. You would provide a different index integer for the left hand, and then in the function return the different set of data. The equipment slot and equipment slot index work together.
getMirrorTargets If you are using equipment mirroring for your equipment this is the function where you will return the additional mirrored targets. Has the same inputs and offers an array of targets for the output. See the equipment mirroring chapter to learn more.
getLeaderPoseComponent If you are using the leaderPose? Option on any of your equipment this function is the one you use to return the main component the others should follow the animations of.
getModularUnequipMesh If you are using modular equipment this is the function you would return the default mesh for the slot when nothing is equipped. If you fail to return anything from this function the mesh will be empty when you unequip.
canEquipThis? This can be used to add additional checks to see if the equipment can be equipped. By default everything is assumed to be equippable. This function gives you the opportunity to validate and stop items from being equipped. You would use your dynamic data to store your additional criteria then this function to validate that against your other systems. Then return the appropriate value based on if the item can be equipped or not. See the Equipment Validaiton chapter to learn more.
changeEquipmentStanceTo Whenever the equipment system changes your equipment stance based on your currently equipped equipment it will send a notice to your pawn using this function and providing the new equipment stance as an input. What you do with this value is entirely up to you. The demo uses it to change our pawn’s camera and animation blend space. See the equipment stance chapter to learn more.
getEquipmentStance A helper function that you can optionally use to return your current equipment stance value. You will need to save the value when the changeEquipStanceTo function is called (it will provide the value), then setup this function to return that variable value. In our demo this is used from our ABP_Manny animation blueprint to get our current equipment stance. See the equipment stance chapter to learn more.

BPI Events

The following events are provided with this BPI_EquipmentPawn blueprint interface:

equipmentAction Whenever an equipment handler wants to notify the pawn of an action it performed it does so using this event. We use this event to send notifications related to all of our weapon related actions. In the demo example we only actually use this event to toggle aiming on our pawn when we use the rifle or pistol. You can see how it works by looking at this function inside the demo character in the Demo/ folder, as well as the simple range equipment handler in the Blueprints/EquipmentHandlers/Weapons/Range/ folder. You can add additional actions to the E_EquipmentAction enumeration in the Blueprints/Variables/Enums/ folder.
WARNING: It is safe to add items to the enum list but do not rearrange or remove any of the current entries from the enumeration. You can easily break parts of the code that depend on the current values. Make sure you review the values of all current references before making any changes.
layEquipmentMontage Whenever our equipment handler wants the pawn to play an animation it will use this event. It will provide the equipment handler, the equipment event (the action), the equipment slot, the equipment stance assigned to the equipment (don’t save this, use the value from changeEquipmentStanceTo to save instead), as well as the equipment row name.

Setting up equipment we attach to our Pawn

You will need to go through these steps for each equipment slot you wish to set up on your pawn.

  1. Make sure the Skeleton you are using on this pawn has the socket attached to the bone you wish to use for the equipment slot. You should always test your socket using a preview mesh before you continue to the next step.
  2. If you haven’t done so already, open your pawn and add the BPI_EquipmentPawn blueprint interface to it.
  3. Open the getEquipTarget function, drag from the Target return node and select Make F_EquipmentPawnTarget. This structure is the data you return with data from this pawn. Here is a breakdown of each of the variables:
isModular? This should be false since you are attaching equipment. If you are using modular equipment you should be following the steps in the next section instead. This section is for attaching equipment to our mesh.
SceneComponent This is the reference to the component (which should already be in your pawn) that you wish to attach the equipment to. You can drag and drop your scene component from the components tab into the graph.
SocketName This is the socket name on your scene component mesh you want to use as the attachment point for your equipment.
RelativeTransform If this pawn optionally needs to provide an offset to the transform for this equipment slot this is where you would provide that offset.

For each of your equipment slots you will return a different set of values.

Now if you're new to Unreal you might be wondering how you can return all these different values with just the one function? There are actually few ways to handle this but I personally prefer using the Select function. This lets us provide a different input value depending on a Wildcard.

To create a Select node drag from the pin you wish to set the value of, and create a Select node. Then connect the Equipment Slot enumeration from the input to the Wildcard on the Select node. This will change the select node to let you provide a different input for each of the Equipment Slot enumerations.

If you only have a single mesh for your pawn like the default Manny and Quinn characters you can attach the SkeletalMesh component directly to the scene component pin, you don’t need to use a Select node.

If you haven’t taken a look at the getEquipTarget function in the Demo Character in the Demo/ folder you should take a minute and check that out. This included example covers all the equipment slots used in the demo world, and also uses 3 different options for the index of our main hand.

At this point you should be able to equip your item on your pawn.

Setting up Modular Equipment

Setup for modular equipment follows the same steps as the attachment equipment, and also uses the getEquipTarget function. Make sure you read through the attachment equipment section first, and then continue with the setup for modular below ...

  1. You should set isModular? to be true. This will tell the equipment system to replace the skeletal mesh with your equipment skeletal mesh instead of attaching it to it. You provide your skeletal mesh component for the slot to the SceneComponent pin.
  2. Use a Select node (as mentioned above) to provide a different skeletal mesh component for each of your modular equipment slots.
  3. SocketName is not going to be used when using modular equipment, you can leave this empty for your modular slots.
  4. You also need to set up a response from the getModularUnequipMesh function for your slot. This is how you tell the equipment system what your default (nothing equipped) mesh is. As mentioned above you can use a Select node to return different values for different equipment slots.

You can also mix and match modular and attachment equipment slots depending on what you need. The key is using Select nodes for each of the variables to provide your different values.

Pawn Related Equipment Animations

All of our equipment animations related to the pawn are handled on our pawn, using our playEquipmentMontage blueprint interfaced event. This event is called from our equipment handlers when we perform our different equipment actions.

By default, the equipment handler will send actions for Equip and Unequip actions and the included examples expand on this to add animations for the melee swings, reloading and shooting of range weapons, and the toss animation for our throwable.

The changing of our pawn’s blendspace when we equip different weapons is a demo example using the calculated equipment stance. You can learn how this works in the equipment stance chapter.

Most Common Questions for Pawn Setup

I can't equip my equipment item to the slot in the UI, how come?
I don't see my equipment when it is equipped, where is it?
I can see the equipment but it is in the wrong spot?
I can see the equipment but the position or rotation is off, how do I fix?
I am using modular equipment and when I unequip the mesh is just empty, how do I fix?
My equipment is showing but it is not following the animations like it should, how do I fix?