Thursday, October 24, 2013

Improving the AI in Assassin's Creed 3...






Tree Hugger


The Assassin's Creed franchise has always been a step above many games in its genre, managing to create a unique experience for its players while maintaining the mechanics and dynamics fans have come to love about the series. With its latest installment, Ubisoft decided to take it all a step further and refresh the animation system without changing the technology much. 

This blog is going to cover the techniques implemented within Assassin's Creed 3 which make it a new experience and far better than any of the previous titles. We will cover the navigation system, the climbing system and the free-running system. The information on this blog has been extracted from a talk on the postmortem of Assassin Creed III's AI delivered by Aleissia Laidacker, the Team Lead and Richard Dumas the Tech Lead at Ubisoft Montreal. This talk was given at GDC 2013 and can be found here.







Introduction

Ten years ago the AC3 team started working on what would become the core pillar and staple of the franchise – the free-running and navigation systems. The technology behind these features really hadn't changed much. With AC3, the team decided to change everything which proved to be a major challenge. They wanted to primarily focus on four main areas: the ground navigation, the free-running, the climbing and a new system called tree-running. The biggest challenge for a massive brand like Assassin’s Creed was to change everything but but at the same time, change nothing. They couldn't change the way the game was played so the core of the game had to be familiar. But they wanted to lift the experience for the player by trying out new technology in their system.

Animation has always been a major focus in the Assassin’s Creed franchise and so with the new game, the team wanted to really invest in procedural animation research. They knew that a big part of the game would happen in the forests. They were inspired by running through a forest in Apocalypto. Essentially, the team wanted to have the character’s movement react to the environment around him. To achieve something like this would mean a lot of challenges. A full forest would mean rocks, slopes, trees and uneven terrain.
The forest specs would be the main challenge.






Ground Navigation

The team realized earlier on that they would have to support not only ground navigation but fights and assassinations as well as all other behavior on uneven surfaces. As such, they invested a lot in procedural animation. The ground navigation would either not work or not look good if they continued using their previous system. In the previous games, they had to tell their level designers to avoid ground inclinations over 30 degrees because although they technically supported it with the IK, it actually looked really bad. So they bridged the gap in AC3 by supporting the ground inclinations in addition to having smooth transitions between the change in height. They wanted to allow their designers complete creative freedom with level set-ups. 

The ground navigation blends with a slope navigation layer so that 0 to 45 degrees looks good. Beyond the 45 degree mark the character progresses into sliding or scrambling behavior. Human IK is used throughout the process to ensure that the foot actually connects. Once the set up to support any ground inclinations was successful, they decided to invest a lot of time into researching how the same could work with any ground debris. They wanted the character to properly connect with whatever object was below him. In the forest they would be a lot of rocks and logs and in the towns there would be a lot of steps and ledges. Simon Clavet worked on a technology called predictive foot placement. 

Over three years there were many different approaches for foot placement. At first it was done using only capsule collision and later there were rays thrown under the feet and then fitting the plan to ground points. This required no prediction. Later, they came up with predicted landing and used highest points on leg swing. Throughout this process, they had to make sure there was compromise between quality and performance. Especially with analyzing the environment, it was crucial to work on optimizations. In the end, based on the animation and the speed of the character they were able to find where the foot was going to step in advance. Then by analyzing the environment through physics casts and ray casts they found the highest point the character would need to step over.







With this information, they were able to have the IK solver position the foot on the detected obstacle and then adjust the pelvis and the height of the 2 feet during the foot placement update. For better quality they worked on something called front strafing which was purely to change the look of how the main character navigated himself through the world. This is something that isn't seen too much in video games nowadays. Thanks to a mix of foot planting and animation they tried to achieve something very different and cool. Traditional video games have rotation of the character based on intention. Usually there is some damping on the rotation but usually it comes down to moving straight and rotating the character. The team at Ubisoft Montreal really wanted to achieve something more natural where the character is able to keep its facing direction while incorporating strafing for the rotations. The end result is a mix of all the technologies developed and some new animations as well. 

So how does it all work? When the character changes directions they move their foot procedurally whether interior or exterior depending on the step that the character is at using the predictive foot placement technology. Also, when the character begins to move in a direction he is never rotated right away. They begin by strafing the player in the desired direction and then activate the rotation. This way, if you’re moving your stick in a certain threshold, the character is really just strafing back and forth and moving him forward without rotations. After three years of research in procedural animation they never got to see their hard work in the actual game until 8 months or so before the game finally shipped at which point it was all about optimizations.

All this tech was made to work for all the NPCs in the game as well. However, there was a limited number of ray casts used for the NPCs so depending on how many there were on the screen at a time, the quality differed. Still, they were able to get the technology to work for NPCs which was an achievement in itself. Some things weren't developed out of a lack of time but in the end the whole team was proud with the final result. The ground navigation was a huge success!






Free running

The team’s initial expectation was not to change too much in the free-running system, but as the game progressed they realized that the style of the free-running reminded them too much of Ezio (the main character from the previous AC games). This didn't really fit with the style of Connor. Luckily, it was around this time that the team had decided to change every single animation in the game so that it would reflect a new style for the game's protagonist. This meant a huge job for the animators on the team, while on the programming side simple changes were necessary to support new variety and opportunities in free running. Ezio’s jump system from the previous games was just a blended animation system – where is it that the character needs to jump, find the animations and blend everything together.

Changes were made to highlight new jump moves in AC3, especially those that would be seen a lot more often in the Frontier. However, the team kept all of the short jumps that blended together since these were very time sensitive and they had no interest in changing how the system worked – they simply wanted to refresh the animations for the short jumps. The long jumps would be one-offs so that the animators could really focus on creating new varieties and different options for those animations. They wouldn't have been able to achieve a unique style with the jumps if the animators had to worry about how they were going to blend with all the jump animations. They also made this work for the animals in the Frontier.







Climbing

The climbing system has been a staple of the Assassin’s Creed franchise since the very beginning. For AC3 they decided to give the system a “good facelift”, as Richard Dumas puts it. For inspiration, they took a look at some very famous speed-climbers. This convinced the team to go over things and make them smoother and faster than ever before. The first thing to tackle was the input system.

Before, there was only support for a vertical and horizontal manner of moving along ledges. Now, the system supports a 360 degree range of motion, essentially allowing the player to go wherever they want in a much more precise manner. The next thing to work on was the fluidity. What they wanted to focus on was preserving the characters momentum as he traveled from one ledge to another. Previously, a normal jump animation would be played fully, followed by the settle animation before the player was allowed to move again. Now, the same jump animation is played but when the end is reached, the system analyzes all the possible traversal scenarios in the environment near the character as well as the player’s input. Depending on these a special link-up animation will be played to whatever move is coming next, whether a jump or a simple movement cycle. This was very costly to do but resulted in a much more fluid system.

Most of the navigation is just a series of small cut up animations that are molded together depending on contextual environment detection. Another thing to improve was the range of surfaces the character would be able to climb. In previous games, most of the building surfaces were flat but with AC3 there were a lot more organic surfaces like rock faces and trees that the designers had to ensure the character was able to reach as they were much further. Crack climbing was a new move added in direct reference to the speed climbers the team took inspiration from. The character would climb vertical rock faces as a pose to the traditional horizontal ones. 







Going Dynamic

The team wanted to go from more of a static world to a fully dynamic one. They really wanted to support unstable rock formations and moving window sills and falling flower pots, etc. They also had to find a way to support all the naval battles with the ships in the game that behaved as gigantic moving platforms. The first change was the introduction of several procedural modifiers on the character so that the body position is constantly adjusted depending on whether there’s a ceiling coming near or making sure that he doesn't stick his out over a building where guards are waiting to spot him. 

The legs were also treated with dynamic contextual detection. This proved to be a harder challenge as they define the support the Assassin lies on.Going from a position where he has his feet on the wall to hanging while moving and vice versa was quite tricky to get flowing smoothly. The body position is even adjusted to ensure that the player is able to grab onto an individual moving anchor making the world and the player’s response to it even more dynamic. Although the system worked really well, it wasn't showcased in the game as much as the team would have liked. They never got to have moving props on building facades due to memory and production constraints. Still, the momentum preservation and follow-through makes the game feel much more fluid and diverse than before. 







Tree Running

The team had to adapt their navigation systems to work with a fully realized forest. Usually a forest in video games is created with invisible walls everywhere to avoid problems and headaches. In AC3, however, the Frontier is the biggest map in the game and completely covered in forest forcing the team to tackle the challenge of supporting such an environment in the game. The team had a few clear goals in mind and many objections.These included making sure that the Assassin didn't climb trees like a koala bear or swing on vines like Tarzan. From a level design perspective, they wanted the trees to act as elevators bringing the player up as fast as possible. This would allow the player to become an immediate predator, hunting down guard and animals from higher up.

There were a few specific tree set-ups used in the game. The first of these was the unclimbable tree which is more of a filler for the artists. Some trees were covered with standard climbing anchors using the climbing system with horizontal branches. This type of tree is slow to climb up. However, once you’re up there, moving horizontally along treetops is very fast. The V-shape tree is the last tree set-up which allows for speedy vertical ascent. It also allows for jumping navigation between trees of its kind. To solve the problem of navigating fast horizontally when you’re up in the tree tops, the Assassin will grab the tree trunk and simply go around it. The game supported all kinds of V-shape configurations allowing the artists and level designers to do pretty much whatever they wanted with the level design. Kick-jump moves were designed to propel the player from one V-shape tree to the other. This was not only much faster than the standard navigation sequence but was a welcome visual change. This is all integrated within the climbing system, thereby allowing the player to quickly ascend the trees and hunt down his targets. 

One of the biggest challenges with creating the V-shape system was making sure that the orientation and position of the trees didn't matter, allowing the system to support everything. The team solved this by creating several ejection and reception animations that link up with the normal free-running system. In addition, the system uses some procedural modifications to ensure that the link up in and out of the V-shape system is fluid to preserve the momentum. The last thing to solve was navigating through the tree tops as fast as possible. This was overcome with the “trunk around” maneuver which was simply a bunch of animations displaying the character circling the tree trunks and combined with free-running and navigation. 

The tree system was actually quite successful because it really allowed the artists and level designers to make an organic forest. In addition, it really complements the free-running system as all systems are well integrated together.







In Conclusion

When the team started on AC3, their intention was to re-do everything but change nothing. They wanted focus on refreshing the second-to-second feeling but not break the experience for the players who knew the system very well. As can be seen through this post-mortem, the animators and AI team worked hard to give the level designers a lot of creative freedom. This meant a lot more work for the programmers and artists, but it was well worth it when the game finally came together as a smooth well-oiled machines.

Assassin's Creed 3 is a fantastic game with an AI strongly based on animation. It works well with the game's mechanics and systems and still manages to stand out in its own right. A well-designed game with a lot to teach us about animation and AI is just over the horizon as we impatiently anticipate the arrival of Assassin's Creed IV: Black Flag.









No comments:

Post a Comment