Creating an Interactable Sword Item, Equipping and Unequipping it to our Player, and Adding Sword Combat Animations
- Watchman

- Aug 12
- 11 min read
This tutorial series is going to use the Locomotion tutorial series as a foundation for our character. If you have not completed that series, I strongly recommend that you do before you start this series.
Importing New Assets
The first thing we are going to do is import the assets that we need, in this case we are going to want to import the model for our sword and of course the animations we are going to need for our sword combat. We are going to be using the "Sword Combat Animations" from Synty Studios. Once downloaded extract the zip folder and we are going to look for the "Models" folder. Inside we want to get our "SM_Wep_Sword_01.fbx" file and drag and drop that into our "Test_Dummy" folder. You will see a window pop up for importing options, but you won't need to change anything so you can just click import.
Next, we are going to open the Textures folder. Inside we have a file named "T_Polygon_Dummy_01". This is going to be the texture file we need, but we have a slight issue. The texture name is identical to our Locomotion texture file, but they are different, and we don't want to replace out existing textures. So, let's rename our texture file from "T_Polygon_Dummy_01" to "T_Polygon_Dummy_02". Then we can drag and drop the file into our content browser.
From here we can duplicate our M_COSTUME material and then open it up. Inside we want to click on out texture sample and change the sample to our newly imported texture.

Open our "SM_Wep_Sword_01" static mesh and we want to set our material as our new "M_COSTUME_02" material.

Next, we are going to import our animations. To do this we are going to navigate to our Content > Animations > Synty folder in our content browser, then create a new folder named "Sword_Combat" and open it up.
Open your downloaded source files and look for the Animations folder, then Polygon since in this instance we are using polygon characters. Then highlight all of the folders and drag and drop that into our content browser. The Import Content window should appear and all we need to do is select our "PolygonSyntyCharacter_Skeleton" in the skeleton section.
Creating New Sockets on our Character Skeleton for Weapon Positions
Navigate to Content > Characters > Synty > Test_Dummy folder and open the Character Skeleton. Inside we can find the "Hips" bone and right click then add socket. We can rename this socket "SwordUnequipped", and then right click on the socket and add preview asset. Search for our new imported sword model "SM_Wep_Sword_01" and then position the sword to where the sheathed location of the sword would be.

When we interact with a sword weapon actor, we want our character to pick it up and this is the location we want to store it.
Inside the "Hand_R" bone right click then add socket. We can rename this socket "SwordEquipped", and then right click on the socket and add preview asset. Search for our "SM_Wep_Sword_01" model and then position the sword to where the equipped location of the sword would be.

Creating a Master Weapon
We will be creating a lot of new folders to keep our assets organized and allow for expansion as we add onto this project, so create the following file path. Inside your "Content" folder create a "Blueprints' folder, inside that create an "Interactables" folder, then inside that create a "Weapon" folder, and lastly inside our weapon folder we want to create two more folders, one that says "Master" and one that says "Sword". While it seems like a lot, hopefully the categories are easy to understand.
Now in the Master Folder we want to right click and create a new Actor Blueprint and name this "BP_MasterWeapon". Open it up and click add, under the components section and add a Scene (Scene Component) then add a Static Mesh component, attach it to the Scene Component, and name it "Weapon Mesh". For our static mesh we can search for "SM_Cube" for a placeholder item.
In the functions, we are going to create a new function named Attach to Player. From the function execute we are going to drag and get an Attach Actor to Component, then we are going to drag the Socket Name back into the Entry Node since we will be receiving that information outside the function. Now we are going to assign the character as the parent, so we can right click and search for "Get Owner" then we can drag from that and get "Cast To Character". We want to right click on our "Cast to Character" and convert to a pure function, then from that find "Get Mesh" and that is going to go into our Parent data for our node.

We need to give our weapon some additional information through enumerations so let's go to our Content > Blueprints folder and create a new folder named "Enums". Once created, right click inside and under blueprint, create a new enumeration. Name it "E_WeaponType", then create another and name it "E_WeaponName". For our E_WeaponType, we want to create two Enumerators. The first will be Unarmed, and the Second will be OneHanded.

Inside of our "E_WeaponName" we are going to create an enumeration called TestSword.
Navigate back to our "BP_MasterWeapon" and in the event graph lets add a few new variables. Let's create a new variable and name it "Damage", then in the "type" dropdown we are going to select Float. Next, we are going to create another variable and name it "Weapon Type", then in the "type" search for our E Weapon Type" Enum. Lastly create another variable and name it "Weapon Name" and we are going to search for our "E Weapon Name" Enum. Lastly, create another variable and name it "Item". In the search bar for "type" find Static Mesh Object Reference.
In our content browser we are going to right click our "BP_MasterWeapon" and create a child blueprint. Let's name this "BP_TestSword".
Now in the Construction Script tab, we want to tell our game what Weapon Mesh we want to display. So, let's delete our Parent reference and from the initial execute find Set Static Mesh. We want to set our Weapon Mesh to match our Item variable. so you can right click and find Get Item, then place that as our new mesh. In the details section we want to set our variables, mainly Weapon Type is OneHanded, Weapon Name is TestSword, and Item is our "SM_Wep_Sword_01".

Creating an Interact Input Action and System
For this portion I strong suggest checking out this guide, where I go through creating the Interaction system. This guide covers how to create an interactable item, set up the communication between the player character and the item through blueprint interfaces, and creating the input action for our Interact action. Due to this already being explained here, I won't repeat it, and we can move on from after we create our interact system utilizing the guide linked above.
Storing Combat Information
Lets go back to our blueprints folder and create a new folder named "Components", then inside right click and create a new blueprint class then select Actor Component. We can name this "BP_Combat" since this is where we are going to store all of our combat information. Before we continue make sure to open our BP_ThirdPersonCharacter and add this BP_Combat component to our Player. Inside of our BP_Combat we can create three variables. "Current Weapon Type" with our variable type being our E Weapon Type and "Current Weapon Name" which is our E Current Weapon Name variable type.


Next we are going to create a Set Current Weapon function. Here we can get an input of our New Weapon which is a Object Reference for our BP Master Weapon. We can drag from our input and set our Current Weapon reference and get class defaults. Here we can find all our stored information for our weapon. We can also adjust our pins for this node in the pin options default category where we can chose what to display or expose as a pin and what not to. We want to make sure that our Damage, Weapon Type, and Weapon Name are all exposed. From our class defaults we can set the associated variables that we just created then connect them to our Return Node as outputs.

Adjusting our Interactable Item to Equip the Weapon
If you followed the Interaction guide then you should have an Attach to Player function for our Master Weapon that looks like this.

What we can do with this is we can create another function named Equip Item. The only thing we need to do in the Master Weapon is add two inputs, a "Character Picking Up" which is a Character Object Reference Type and "Stored Weapon Slot" name type variable. This way when we open the TestSword Item we can reference the parent function.
That being said lets navigate to the TestSword and open the Equip Function through the dropdown next to the add function icon. We are going to drag from the character picking up and Get Component by Class and set our class as BP_Combat. From there we are going to promote that return into a variable and name it Combat Component Reference, drag from than and we can get our Set Current Weapon function and connect the reference to the target. Next we are going to connect our Attach to Player function and from the input connect our character picking up and stored weapon slot. Lastly, make sure to create a reference to self for the New Weapon.

Back on the event graph for our item we can get a reference to self and get class for our Weapon Class input for our Equip Item. We can also use our SwordUnequipped name variable, and Character picking up to transfer that information to our function.

Setting Equip and Unequip Animations
Now that we have our weapon setup we can head to our animation folder and create a new folder named AnimationNotifys. Once inside we can right click and create a new blueprint class and search for AnimNotify. We can call this BP_EquipAN. What an animation notify is, is essentially a cue that we can place within the duration of an animation to complete an event like a sound cue or function. In this instance what we are going to do is utilize a function to communicate to our game we want to move our sword from our sheath to our hand when we reach for it during our animation.
To do this we can open our new animation notify, BP_EquipAN and we can get the owner from the Mesh Component which will be our actor. Then we can get the component by class from our actor. With this we can get our current weapon that we set, and we can access our Sword Equipped Name variable. From the Received Notify execute we can cast to character then call our equip item function and assign the current weapon as the target, and the sword equipped as the slot. Now from our character cast we can drag into the character picking up. The last thing we want to do is in out BP_Combat we want to create a Boolean variable to track whether or not we are "Combat Ready", after we create that we can now in our animation notify set that after we equip our item.

We can duplicate this Animation Notify and call it BP_UnequipAN. The only things we need to adjust is the socket from sword equipped to sword unequipped and set our combat ready to false.
Now that we have our animation notify set up we can navigate to our Content > Animations > Synty > Sword_Combat > Idle > Sheathed and locate our "A_Draw_Sword_Masc" animation. Right click and create Animation Montage. Inside of our animation montage we can look for the point where our character grabs his sword and right click, add notify, and select our equip notify. We also want to add a slot and Name it UpperBody, then assign it for this montage.

We are going to do the exact same thing for our "A_Sheathe_Sword_Masc". Create an animation montage, find the point where the item transfer should occur, and set the slot to our new UpperBody slot.

Creating a Toggle Weapon Action
We have two more things we have to set up for our sword combat. One being a Toggle Weapon Action, and the other being adjustments to our Animation Blueprint. We can take care of the Toggle Combat first. To do that we need to create a new Input Action and name it IA_CombatToggle, then we can use our Input Mapping Context and set the R Key to be what we will use to initiate our toggle.
Inside of our Third Person Character we can right click and get out IA_CombatToggle, then we can create a branch from our started execute. Here we can set the condition is that our current weapon type from our BP_Combat is not unarmed. We can do that by dragging our BP Combat component down into our graph and get our Current Weapon Type variable then from that set a not equal condition for unarmed. We also want to create a new Boolean variable and name it "Can Perform Action", then we can connect the two using an AND Boolean node and set that as our condition. If the branch is true then we can set our "Can Perform Action" to false and then create a switch using the same current weapon type reference. If the enumeration matches One Handed then we can create another branch and set the condition that the character is combat ready from our BP Combat. If true then we can play our Sheathe sword animation, and if false we can play our Draw sword animation. We can do this by using the play montage node and setting our characters mesh as the Skeletal Mesh Component and our Montage as the montages we made earlier respectively. Afterwards when we complete our animations we can set can perform action back to true. This prevents us from spamming the action and not letting it complete.

Adjusting the Animation Blueprint
In our AB_Synty we can navigate to our event graph and we want to reference two variables we created earlier. To do that we are going to right click and find "property access" then under our Third Person Character, then BP Combat, then our Current Weapon Type variable. Now promote the result and name it Current Weapon Type. We will do the same thing to get our Combat Ready variable from our BP Combat. These will be added on to the sequence for our other variables such as sprinting and crouching.

Now in our Anim graph we want to make a few changes. Right now we just have our State Machine for Locomotion going into our Output Pose, but what we want to do is to first add our DefaultSlot before our Output, which we can do by right clicking and searching "defaultslot". Now we can duplicate out default slot and select our new UpperBody slot in the Slot Name in the details.

With our Upper body slot we want to separate that from our lower body on our character so we can do a few things. The first thing is to get our locomotion state machine and from it find New Saved Cache Pose and name it Locomotion. Then we can duplicate our Locomotion State machine and name it Sword, then save that as a New Saved Cache Pose.

With our cached poses we want to chose which one we use based on our Weapon Type variable, so we can right click and "Use cached pose" in this case Locomotion and from it find "Blend Poses (E_WeaponType). Locomotion will be our default. Right click on our Blend Poses node and add pin for element "One Handed". Here we will use our saved cached pose for "Sword". from our Blend Poses we want to do a Layered Blend per bone with our Locomotion being the base and our Blend Poses based on our Weapon Type Enum as our Blend Pose. Now click on the node and under Layer Setup we want to add our Spine_01 with a Blend depth of 5 to our Index. The output of this we can save as "Upper Body".

Now we can duplicate our Layered Blend per Bone and use our Upper Body cached pose as the Base and also as our Blend, but we can add our New Slot "UpperBody" from our Animation Montage between the saved pose and the input. Our blend node goes into our Default Slot, which then goes into our Output pose.

The neat thing about our setup now is we can edit our Sword State machine and set up the Player's idle animation when they have a sword and are combat ready. So in our Idle State for our state machine we can do a Blend poses by bool and set the bool as Combat Ready, and we can set our true to our "A_Idle_Base_Sword" and our false to "A_Idle_Sheathed_Sword_Masc".

We can also in our Locomotion State take our BS_Locmotion blendspace and do a Layered Blend per bone from the Clavicle_R bone using our "A_Idle_Base_Sword" animation to allow our character to hold our sword while they are moving around. But we will have to do a layered blend by bool in between to ensure it only happens when they are holding the weapon.

Now we should be able to pick up our sword item and it attaches to our unequipped slot, tell the game we have a sword, and then we can toggle our combat ready which allows us to pull the sword from our hip to our hand. When we have our sword equipped we have a new idle pose and it blends with our locomotion blendspace so we can hold it in our hand while we run.



Comments