Designing AI to do anything a spider can in Marvel's Spider-Man
Marvel’s Spider-Man was a huge undertaking for Insomniac Games, and one that represented the largest game the studio had crafted to date.
The size of the game, along with the numerous different enemy factions and a cityscape that evolved throughout the game, led to a good deal of AI problems and interesting solutions, something lead gameplay programmer Adam Noonchester dove into during his AI Postmortem today at the Game Developers Conference.
Spider-Man’s combat is a fluid myriad of dodges, web-slings, and combos and the AI team had a couple of helpful tricks up their sleeve to capture that very Spider-Man feeling throughout the game.
For aligning Spidey himself with his target, Noonchester says they relied on sync joints and anchors to orientate the two combatants on the fly. Those two sync joints, one on Spider-Man and one on his target would line up to each other, match up, and allow the animations for the brawl to connect.
There were a handful of different anchor techniques they used depending on the situation, he explains, and as a bonus, the team was able to use camera zooms to mask some weirdness that emerged through animations because of how this system worked. However, the system was only set up to handle one-on-one animations so when the topic of finishing moves taking out more than one enemy was mentioned later in development it didn’t jive with the established system.
Height adjustments also proved to be an issue, but one that the team often had to just roll with. As highlighted in one slide: “Did you know that most game worlds aren’t flat? Did you know that most mocap studios are?”
There are issues you fix and there are issues you roll with, and Noonchester says some of the height differences in combat flows belonged to that latter category.
“We can’t always fix things,” he says as an image of Spider-Man punching toward the kneecaps of an enemy on higher terrain pops up on a screen. “And then we just deal with things being off.”
One of Noonchester’s main points throughout the talk was how important iteration is to the development process.
“I hope it’s obvious but it took quite a few tries to get things that you saw in this presentation to where it is now.”
Time and time again, Noonchester said the team implemented AI changes that sought to find the balance between flow and difficulty. This became a system where an attacker token was essentially passed around to different members of an enemy group to control the pace and keep enemies from mobbing Spider-Man all at once or attacking too infrequently. Different actions affect the token’s holder and behavior, so if an enemy gets too far from Spider-Man the token resets to another foe that’s already ready to attack, or when a player performs a dodge there’s a momentary enemy idle timer that kicks in to give the player a change to get a few good swings in.
However it was too easy for playtesters to feel like the enemies were scoring cheap hits, so iteration was key to discover the systems that eventually captured that Spider-Man flow. Ranged combat added another layer to that complexity, but they eventually worked out a system that prioritized attacks from on-screen enemies to avoid the feeling of cheap hits, and made off-screen enemies take longer to fire ranged weapons in general to give the in-game “Spidey Sense” a fraction of second longer to alert players of an incoming attack.
On top of that, invincibility frames were added to combat animations so players wouldn’t feel like enemies were knocking them out of already executed attacks. The system isn’t perfect, and there’s a fair deal of exceptions that come into play—“We’d cancel incoming attacks…unless you repeatedly used them…unless its a dodge…unless its in a boss fight”—but the version that shipped with the game managed to accomplish combat that avoided having players feel cheated by the in-game AI.
The solutions the team eventually used in the final game weren’t their first attempts, and trial and error were key to getting from the things mentioned in his talk to the features the game itself would eventually ship with. He highlights the importance of facing new problems and finding new solutions to those, rather than just resting on things that have worked in past projects.
“I believe that Marvel’s Spider-Man was a success because everyone said that the game made you feel like Spider-Man,” concluded Noonchester. “This wasn’t an accident and I believe it was because we made the core […] feel right.”