Combat
Every time the player swings the sword, a sphere trace tracks when it makes contact with an enemy. On contact, a function is called to apply damage to the actor. The most difficult part of this system was to ensure that the player couldn't damage enemies without swinging the sword. In the blueprint that handles the sword animation, I made sure to check that the player: 1. has the sword equipped, and 2. has enough stamina to swing the sword. Then I set up notifiers in the animation montage, which allow the sword traces to be triggered at specific points in the animation. Once the player stops swinging the sword, the trace disappears (preventing damage to occur) and the player beings to regain stamina.
The target lock is an input action that sends out a sphere trace based on where the camera is looking. If the trace hits something that can be locked onto (an enemy), the player is oriented toward it. While locked onto a target, the player will always face it no matter what, which allows for strafe movement. Once the input action is triggered again the camera is released to be moved freely again.
Healing
Upon triggering the healing mechanic, an animation is played to make it look like the player is drinking a potion. During the animation, the movement speed is set to zero, which is meant to prevent the player from spam-healing and punish them for healing at in-opportune times. Since the animation utilizes the same hand the sword is held in, I made sure to disable swords visibility during the animation so that it doesn't look like the character is trying to eat it. Finally, once the animation completes, the player's health is restored by 20 points. 
Pick-ups
 Each equipable item has a data asset associated with it that saves information like name, 2D asset, 3D asset, ect. Items are picked up through collision, which then calls a specific function depending on what is picked up. For example, when the sword is picked up, the mesh is socketed to the character's hand and its icon is set to the second inventory slot. The player can't use items unless they are picked up, so the sword swing animation and damage won't trigger unless the sword is equipped. The inventory itself is just an array of icons that gets updated when the player picks something up. 
Dodging
The dodge direction is determined by the player's current direction (forward, back, left, right). This also includes the direction of the strafe when locked onto a target. When the dodge action is called the stamina is checked first. If the player doesn't have enough stamina, they cannot dodge until enough is refilled. If there is enough stamina to dodge, then an animation montage is called to put the character into a roll. During the dodge, stamina is depleted by 25 points, which can be regained after a short period of not dodging.
Reflection
The goal of this project was to explore blueprints more in-depth than I ever had before. I learned a lot about implementing blueprint interfaces in Unreal Engine, which I used for the combat and interactable items. I previously learned how to use interfaces in Java, so it was interesting learning how to use them in Unreal. The most challenging part of this project was all the intricate parts connected together, but I had a lot of fun researching and trying new things. I hope to expand on this project in the future to create a full experience.

You may also like

Back to Top