- An Among Us programmer joins us to explain a key piece of code from the game.
- This multiplatform game makes it look easy to host players from a dozen different systems.
- The game is built in the popular Unity engine, with C++ and C# code behind the scenes.
In the hit game Among Us, a group of players are dropped into a spaceship and given small tasks to do like maintenance and engine repair. But for one player, the “small task” is to kill all the others. The game came out in 2018 but experienced meteoric success beginning in 2020 as a party game that groups could play together virtually. It’s a fun game to begin with, but it also illustrates some cool things about how computer games are made and designed. We talked with Shahrin Khan from Innersloth, the makers of Among Us. She shared a piece of code from the game that will help us tell the story.
How the Game is Played
Among Us is a game for up to 15 players. Everyone chooses colors as well as accessories, like hats or pets, in a main holding area. Once the match starts, up to three players are chosen to be impostors and the rest are regular players. This is an asymmetrical roles game, because impostors have a different set of moves and abilities than the rest of the players. You may know popular asymmetrical horror survival games like Dead By Daylight, where killers and survivors are pitted against each other. In Among Us, the crew members try to survive. The impostor can travel through hidden vents, with the goal of trapping and killing players where others can’t see them. Then everyone gathers to vote on who they believe the impostors are.
Why This Game Attracts Users
One of the big draws of Among Us is that the game supports cross-platform play, meaning people with the free Android app can join games with people on the Nintendo Switch, PC, and other consoles. The game is made in Unity, which is a game engine: the software that supports and underpins game development by including a lot of existing features and libraries that developers are likely to use.
First released in 2005, Unity premiered as a Mac engine before building in support for almost every other kind of platform, from Linux to consoles. It’s even free for many users, because there’s a floor of $200,000 annual revenue before an account switches to the paid Unity Pro version—and developers who make over $200,000 a year are rare. Because of its “democratizing” philosophy, Unity also has a huge community of people who contribute assets for others to use in their projects. For small studios and individuals, that means saving time and money on building assets like character models and backgrounds.
The Programming Languages That Work
Unity uses both C++ and C# programming languages. Coding is very generational and iterative, with languages that add features and traits over time. C++ and C# date back to C, which was introduced in the 1970s but remains popular today as a way to code operating systems and hardware. (It’s not even the oldest language still in wide use; COBOL, popular for accounting and batch banking systems, dates back to 1959. There are likely others!)
C++ is the backbone of a lot of video game programming, partly because it was designed to interact with hardware in an energy efficient way. That means software written in C++ can run more efficiently while tapping into computer hardware features like graphics and RAM. C#, in turn, was purportedly designed in response to the Java language. (The sample Shahrin Khan sent me looks so much like Java, a language I’ve used more myself, that I initially mistook it for that!)
Let’s Look at the Code
Khan writes code for Among Us in an integrated development environment (IDE), software that makes it easier to look at and work with code by using features like color coding. We'll have to do without in this sample!
This is a method, which is a block of code that only runs if someone elsewhere “calls” it. Calling SetHat(15) is like typing 15 into your calculator then pressing square root, except instead of the square root, the method is changing the color of your hat. “It assumes that you already know which hat to wear, but the color is changing,” Khan explains. The color options are stored under integer values, because that’s much easier than asking the computer to parse, or interpret, a color name written out as a word.
Then the code turns the color code integer into something that makes the change in the Unity engine. This change actually applies the right visual information to the art depicted in the game. “It eventually starts a coroutine—basically, something Unity tries to do in the background while also doing other things so that the game doesn't appear frozen—to load the ‘view data’ for the hat,” Khan says. “Once we've loaded in the texture, we finally used the color ID that's been passed to us in order to color the hat appropriately.”
Games, especially multiplayer online games, are always balancing a lot of streams of information at the same time. And this is true of most other uses of computing too. We see all our open apps or windows and think of them as separate streams that are all going on at once, but that’s because of programming that staggers each process’s “next step” so that it all appears to be uniform. In reality, it’s more like strumming a guitar: you’re technically hitting one string at a time very close together, creating the sound of a chord.
Among Us has over 300 hats, and they represent a big part of the game’s financial model. The Android app is free, and other versions of the game are quite low cost; but all players can pay for in-game currency that can be used to buy themed cosmetic packs for the seasons, holidays, and other special events. “The most fun about hats personally is seeing all the pun-based names for them,” Khan says. “I really wanted to come up with a good pun to say that, but I couldn't.” (A good hat pun is hard to top.)
Hats are fun but there’s one big drawback, Khan explains. “One challenge is memory management. A lot of older mobile devices are not able to have too many assets loaded in the game at once, which has resulted in crashing issues for some users. This is something we need to be cognizant of whenever we add new cosmetics of any type, hat or not,” she says. And that makes sense, because the more complex a game experience becomes, and the more different art is being used and managed during gameplay, the more pressure there is on the computer processor and memory that power the device.
If a change were ever made to the SetHat method above, there’s a very specific process for introducing the change into the code, and eventually to players. Khan would make the change locally on her own machine, then test it. (Testing isn’t just one step or location in the process—a half a dozen different types of testing exists, and some are used multiple times during development.) From there, the new code would be loaded into shared files in Innersloth’s GitHub, an online service that tracks changes and versions of software.
“Every night, we have an automated system that takes our working code base and creates an executable or ‘build’ from it for various platforms like Steam, Android, and so on,” Khan explains. “The following morning, those builds will be ready for our [quality assurance (QA)] team to test it out. If it passes their tests, then the change is considered functional and ready to go into the next update.”
Sometimes, changes are urgent, like new code that fixes an error that makes the game crash. Other times, the code is for performance improvement, new features, or fixes for esoteric and uncommon bugs that don’t have the same urgency. Development teams decide together when they want to plan updated versions of their software. It can also roll out at different times across platforms.
Khan had a few coding jobs before working on Among Us, including six years as a Unity developer at a mobile games company. She says she was surprised how cool the team is at Innersloth, which is always a great thing in a job. “I think the main thing that was surprising is how great the team is, and how much fun we all have working together,” she says. “That sounds very cheesy, but it's true.”
This content is created and maintained by a third party, and imported onto this page to help users provide their email addresses. You may be able to find more information about this and similar content at piano.io