Development of a player character with responsive and versatile aim posing.
Anew: The Distant Light is a Metroid-style open-world game currently in development and nearing feature-complete. (We also have a Kickstarter for it underway.) One of our frequent touchstones for this game has been fluid tactical combat with a very responsive and agile player character. The core combat is built around tension between skillful gunplay and well-timed use of your slowly recharging energy shield.
The gunplay side of things brought some interesting technical and artistic challenges related to how the hero character aims, poses, and animates. We're not doing anything novel with the implementation, but we’re quite happy with our result and I thought it might be interesting to share our approach and thought process.
There were a few ways to pursue development of the gameplay that I had in mind, but the main specifications settled on were:
Traditional twin-stick controls for 2D movement and aim, with precise, 360 degree play
Player character’s pose should very accurately convey the effective aim
Controller input should result in instant and continuous aim response on the player character (for all but the heaviest weapons)
The player should be able to aim and fire during every other character action, to allow for deep gameplay and a high skill cap
Retain as much of a hand-animated look as possible throughout all actions
The first one was straightforward. Use the left stick’s movement input for the aim input as well, unless the right stick is in use (outside of a dead zone that feels right for that specific kind of controller). For aim direction, create a vector in screen space by adding vectors for the vertical and horizontal joystick axes and then normalize the result. It’s sometimes best to map movement input to world space or local character space, but screen space works well for aim in a side-scroller. That keeps aim input intuitive for a player if the character ever runs over irregular terrain, if the camera rotates, or if the direction of gravity changes. We do all three.
The character’s arm then needed to extend in the direction of aim while the player is shooting or even starting to pull the trigger. Since the right stick was dedicated to aiming, the arm could also extend when the right stick was in use to give better aim feedback even when not firing.
Key Poses and a Blend Tree
To get the character’s pose to reflect 360 aim input, I started with the idea of having custom poses for key aim directions and then tweens could be resolved in a blend tree parameterized by the aim angle (converted from the aim vector). My development partner, Jeff Spoonhower, whipped up the following poses.
He took care to keep the hand position on the XY plane for each pose while maintaining the Z position of the hips. Each pose also had to provide a feasible transition to the adjacent ones while minimizing mesh interpenetration during tweens. This can be tricky, especially with stylized anatomy. We’re also masking out the lower body animations for these poses so the character can walk, run, jump, climb, slide, hang, jetpack, swim—whatever—and keep on aiming and shooting without interruption. So, Jeff additionally had to be careful how he rigged the character and which bones were used to achieve these poses.
Why was it so important for the aiming hand to stay on the XY plane for this game?
Anew: The Distant Light is simulated in 3D for various reasons, but most gameplay happens in 2D on an XY plane, including simulations of the player character’s gunfire. If the hand or gun muzzle ended up off-plane, it would create a disconnect between the simulation and the visualization. We might have been able to overlook this for an orthogonal projection camera, but our perspective camera would likely reveal such flaws. So, we had to revisit the original poses a few times.
Since this approach allowed the pose to be resolved on the same frame as player input, it created a very responsive result. The aesthetics were decent for a first pass as well, but many flaws were evident.
For one, the character's lower body looked very stiff if he was aiming while standing still. So, we created a full body aim pose set and blend tree which is used instead for this special case.
Also, the tweening between certain poses pulled the hand out of alignment due to how interpolation works with joint rotations. The ideal arm stretch was going to be different for different weapons, and we didn’t want to create a new pose set for each gun. Further, we wanted more control for a gun’s roll on its local X axis than a blend tree would easily provide. The most direct way to address these and other issues seemed to be Inverse Kinematics.
For IK, the gun’s position and orientation would need to be procedurally set to match the aim input. The gun transform also had to be unparented from the hand in the character rig during the aim and reparented during other animations. This way, there was only one system determining gun placement at any given time.
For gun position, I added the center of aim sweep to the aim vector multiplied by the desired gun offset. The gun would obviously need to point in the direction of aim, but also have a rotation that worked with the character’s anatomy. Further, I wanted each gun to show its signature profile most of the time so that it could be easily recognized even when the camera was distant. (This was a trade-off for a possibly more aesthetic smooth roll of the gun on its local X as the character’s arm twisted to aim backwards.) So, I ended up rotating the gun on Z to match the aim vector, and then flipping it on its local X axis when aiming backwards, just past vertical. With that settled, the arm could be iterated through an IK solver to reconcile its joint chain, all on the same frame.
Things were looking even better with IK, but it raised the question: Were the aim poses even necessary?
Without the aim poses and their tweens, the rest of the player character’s body just didn’t end up in a reasonable position and in some cases the IK solver couldn’t even reach the gun. We could have extended the IK chain past the shoulder with a custom solution to get some torso twist, but then what about the head? It’s a nice detail that he looks where he’s aiming. His off-hand also counterbalances his center of gravity with a raised aiming arm. In practice, there were many aesthetic benefits to starting with hand-crafted poses.
Turning to face another direction while holding aim caused the arm to cross over and pass through the body for half of the cases. The internal simulation for Anew: The Distant Light has the player character turning instantly to change facing left or right, but the animation takes a split second to catch up as it plays an “about face”. We experimented with snapping the model to the new facing in one frame, but it felt cheap. Experiments with mirroring the poses for facing left, as one might do with a sprite-based game were also unsatisfying. We wanted better continuity of motion through these poses, provided the character still felt responsive. Further, continuity of anatomy through the turns seemed important for the look we wanted—the gun hand should always be his right hand for both facings. Having already achieved a good result for turns, we didn’t want to compromise it when guns were added to the mix.
When facing either direction, the player character is rotated a bit toward the camera for better presentation. For the same reason, he also turns in the direction that will maintain a torso facing the camera, left-to-right or right-to-left. When continuously holding aim, however, he needed to turn in the direction that would unwind his body to relax the aim pose: clockwise or counterclockwise. The solution looked much better and we were getting close!
We were quite happy with the results at this point, but not quite into diminishing returns. The character’s gun grip needed to precisely fit the gun he was wielding. For this I created a separate state machine to determine the hand pose. Through this, animated blends between a gun-specific grip, a relaxed hand, and a sprinting hand are regulated.
It took quite a bit more experimentation and handling of special cases than we expected, but we feel that it was worthwhile to achieve a result that will hopefully stand out in aesthetics and gameplay.
Steve Copeland and Jeff Spoonhower have worked on games in franchises such as Bioshock, Borderlands, Star Wars, Uncharted, Lord of the Rings, Command & Conquer, Saints Row, and others. They are co-founders of Resonator and comprise the two-person team developing Anew: The Distant Light, which currently has a Kickstarter underway. Please stop by and join the conversations there.