Devlog: Overhauling Squad Movement and Formations - Keegen Love
Part 1: The Problem
During the recent overhaul of the squad movement system, I encountered multiple issues related to inefficient squad tracking and coordination. Originally, every member of the squad was constantly aware of the positions of the other members, resulting in a lot of unnecessary calculations and frequent confusion about the squad’s movements. This led to erratic behavior, where squad members would often get stuck or lose their synchronization, especially when their targets were destroyed or moved.
This was compounded by the way animations were handled. Attacks and other animations would often get abruptly cut off, leaving squad members in an incomplete state of attack, where they'd wait endlessly for confirmation that the attack was handled. These issues not only created undesirable movement and behavior but also significantly impacted the user experience, making the squad feel unresponsive and difficult to control and disabling the confused heroes from attacking.
Part 2: Problem Solution
To solve these issues, I first focused on decoupling the movement of individual squad members. The solution came in the form of a new approach to an old system, SquadParent
—an independent actor controlled by the player—which handles the squad’s destination. Before, the SquadParent would clumsily handle the positions by having each member painfully aware of where every other unit was, where their target destinations were, and what the state of everyone in the squad was.
Now, the SquadParent
gives orders to the squad, but each member only cares about the path it needs to follow, without constantly checking the position of every other squad member. This change alone improved the coordination of the squad, as each member now follows their own path toward the destination, without the need for constant and unnecessary communication between squad members.
One of the most important improvements I made was restructuring how squad formations are handled. Previously, the squad members were not in a clear formation and would often spread out or group randomly when moving. To address this, I created an ENUM
to handle different squad formation types, such as:
- Line Formation: The squad members are arranged in a straight line, typically with a single row of units. This formation is ideal for straightforward movements, ensuring that the squad moves cohesively in one direction. It’s often used for simple attacks or when the focus is on a single target ahead.
The Squad in a Line formation - Square Formation: In this formation, the squad is arranged in a square shape, with an equal number of units on each side. It provides a balanced defensive posture, where each member is supported by others on all sides. This formation is great for holding positions and protecting a specific point.
The Squad in a Square formation - T-Shape Formation: The squad is arranged in a "T" shape, with one row of units at the top and additional units forming the vertical stem. This formation allows for a strong focus on a single direction or target while keeping the squad flexible for repositioning or adjusting to threats from the sides.
The Squad in a TShape formation - Inversed T Formation: This is the reverse of the T-Shape formation, with the vertical stem at the top and the row of units at the bottom. The Inversed T formation is effective for setting up a strong defense at the front, while the rear row can quickly adapt to threats from the back or sides.
The Squad in a Inversed-TShape formation - Diamond Formation: Units are arranged in a diamond shape, with one member at the front, one at the back, and two on either side. This formation provides a balanced offense and defense, allowing the squad to focus on a central target while offering protection on all sides. It’s great for versatility in combat situations.
The Squad in a Diamond formation - Minus Formation: The squad forms a shape resembling the minus sign (–), with units spread out horizontally and a gap in the middle. This formation maximizes area coverage, ideal for controlling wide spaces or engaging multiple enemies. It’s often used to secure a larger area or prevent the enemy from breaking through the front.
The Squad in a Minus formation
These six formations give the squad a variety of options to adapt to different tactical situations, whether you're focusing on defense, offense, or area control.
Implementing the ENUM
based structure and exposing it to unreal's blueprint system allows for easy external access and management of the formation type, making it much simpler for both BaseSquad
and SquadParent
to stay focused on their respective roles while still being able to communicate through the formation settings. The SquadParent
can easily dictate which formation the squad should adopt, and the squad members simply adjust their positioning based on that choice.
By using this ENUM
, I also ensured that squad formation management was streamlined, making the system more flexible and easier to maintain. The ENUM
is not only easy to extend for future formation types but also ensures that the code is more organized and modular, reducing the complexity of having to manually track and assign formation settings in multiple places.
Additionally I, in collaboration with Ivan (our Team Lead), addressed the animation issue by ensuring that each animation was consistently considered completed before transitioning to the next. This was done by implementing a more robust animation state system, which ensured that attack animations didn’t get interrupted by other behaviors. I also tweaked the timing of when targets were destroyed or hurt, ensuring that the animation stayed in sync with the action.
Before, if any of the Heroes were to get hit while attacking, the damage would be dealt, but the unit would abruptly start issuing a hurt sequence before the attack sequence could be considered finished. Without an ability to snap out of the Attack task, any unit affected by this would be permanently stuck, waiting for the task to be resolved. What made matters even more confusing, is their shared information would still be updated properly, regardless of the frozen behavior.
Part 3: Performance and Future Plans
One of the great results of this overhaul was a noticeable improvement in performance. By removing the unnecessary interdependence between squad members and focusing on their individual paths, the overall movement system became much more efficient. Squad members no longer had to check on each other constantly, and the squad as a whole was able to move more fluidly and with less computational overhead.
This also allowed me to work better in tandem with Violet, our UI and Animation Programmer, to implement a conducive feeling HUD to easily reposition and reform the squad at a moment's notice.
A newly overhauled system means an easily modular structure for adding dynamic rotations to the behavior in the near future as well!
Part 4: Conclusion
The overhaul of the squad movement and formation system solved several key issues and vastly improved both the squad’s behavior and the player’s control over their squad. By pouring some tender love & care into the SquadParent
system and using an ENUM
to manage formations, I was able to streamline squad behavior and reduce unnecessary complexity in the code. This allowed for smoother, more intuitive movement and better coordination between squad members.
Additionally, fixing the animation state transitions ensured that animations no longer interrupted each other, making the gameplay feel more polished and responsive. With this overhaul complete, I’m excited to see how these changes will support future updates and feature additions, including more complex squad tactics and dynamic behavior!
Get Return to Divinity
Return to Divinity
Strategic combat, tactical formations, and perilous dungeon runs—can you survive the depths?
More posts
- Devlog: Hero Classes and Special Abilities - Ivan Shyika16 hours ago
- DevLog: Implementing Death (Animations) - Violet Weathersby16 hours ago
- Devlog: Preserving squad data across levels - Ivan Shyika6 days ago
- DevLog: Squad Selection Crashes - Violet Weathersby6 days ago
- Devlog: Fixing Squad AI Freezing in Combat: A Deep Dive into Task Instancing and...6 days ago
- DevLog: Camera Issues - Adam Denomme6 days ago
- Devlog: Designing interaction between player and autonomous AI - Ivan Shyika13 days ago
- DevLog: Creating the Player HUD - Violet Weathersby13 days ago
- DevLog: Fixing Invalid Click Locations in Pathfinding - Keegen Love13 days ago
Leave a comment
Log in with itch.io to leave a comment.