Specialization
Posture-based Combat System
Systems design, AI & responsive combat in Unreal Engine 5
⌄Posture-based Combat System
Since the first time I played Sekiro: Shadows Die Twice, I have been wanting to
create my own high-stakes, posture-based combat.
I have also wanted to learn how to use Unreal Engine 5. This was my very
first project in UE and I aimed to mainly use C++, while also trying out UE's own systems.
In Sekiro, the combat is focused around a posture system. Both the player and the enemies have a
posture meter that fills up when they take damage. Once the meter is full, the enemy is
staggered, opening them up for a powerful attack.
This mechanic creates a high-stakes environment where players must carefully time their attacks
and defenses. It can be very frustrating for players who are not used to this style of combat,
but it is also very rewarding when you master the timing.
The Development Process
Most of the early process was focused on learning the engine's architecture. Setting up the
foundation took time, as I was navigating Unreal's framework for the first time.
I started with the 3Cs (Character, Controls, Camera). Getting the movement and
input handling right in C++, before implementing parry and posture
logic.
For the camera I implemented a lock-on system for the current target of the player. If you
input the lock-on command, the camera will find the closest enemy and lock onto it.
The camera will then rotate around the player to always keep the locked-on target in view.
If there is no enemy nearby, the camera will instead rotate so its facing the same
direction as the player.
While the player has an active target the hud updates and displays the target's health and
posture.
Combat
Sekiro-style Mechanics
AI
Implementing a Sekiro-style boss required a look into Unreal's Behavior Tree
system. I used Blackboards to manage the boss's awareness and state transitions.
To solve positioning issues, I implemented EQS (Environment Query System). This allowed
the AI to dynamically evaluate the arena.
I tinkered a long time with the bosses animations to get the wind up and timings, that all
souls-like bosses have.
Each swing of the enemy also lunges towards the player and keeps its rotation until the
swing is complete. Giving the player a brief window to dodge out of the way
When the bosses posturemeter reaches 100%, it becomes fully stunned allowing the player to
execute a finisher. The finisher instantly kills the boss.
The boss also has a "staggered" state, which is triggered by successful parries. In this
state the boss is more vulnerable and allows the player to get a few attacks in.
After you have successfully executed the boss it reaches stage two. The only thing that
changes in this stage is that the boss has a chance to perform new attack, which is a large
area-of-effect lightning attack.
Combat Logic
Attack and Parries
I used Unreal's animnotifies to trigger attack windows and parry timings.
The colliders are set to sockets on the weapons. They get activated and deactivated by
the animation events.
As it is in Sekiro, there are certain frames in the block animation where the player can
parry. So if the player gets hit
during these frames a successful parry is registered, and the boss's posture gets
damaged.
If you parry too early, you will do a block instead which damages your posture but not
your health.
When getting a several successful parries in a row, the AI would enter a "staggered"
state,
allowing the player to get a few attacks in.
In Sekiro they have a certain mechanic where if the player jumps and blocks while being
hit with a lightning attack, they can avoid the lightning damage and instead input an
attack to reflect the lightning back.
I wanted to implement this as well, so in the bosses second phase it gets a lightning
attack. If the player is grounded it takes damage, but if the player jumps and blocks at
the right time, they can reflect the lightning back at the boss.
This results in the boss taking both health damage and posture damage, and also gets
staggered.
Takeaways
Project Reflection
This project was a lot of fun but also a significant challenge due to Unreal Engine
5.
Having never used Unreal before, I had to quickly get up to speed with its framework.
Mainly using C++ there were some challenges. After having many issues I learned
that when adding new properties that changes the reflection system in my header file, I had to
close Unreal Editor.
There were several times where the program would behave in weird ways, only getting fixed when i
removed the temporary files in the project directory and regenerated the Visual Studio project
files.
I had a lot of success using Unreal's built-in systems, such as the Behavior Tree and EQS for
the AI, and AnimNotifies for the combat timings.
Especially tinkering with animations was a rewarding experience, allowing me to create more
dynamic and responsive characters.
The result is a combat system that feels punishing, responsive and fun. When I had others try out the combat, they all wanted to try over and over again, until they managed to defeat the boss. Now that I am more familiar with Unreal Engine, I am excited to explore more of its capabilities and create even more complex systems. I am looking forward to applying these systemic design principles to even larger architectures in the future.
If I had more time I would like to implement more enemy types, leading up to a final boss. I
would also like to implement more of the mechanics from Sekiro, such as the grappling hook and
stealth mechanics.
Sekiro also has several different unparryable attacks that require different inputs from the player to counter. These would be fun to implement as well, to add more variety to the combat.