Among Us, a programmer gives a behind-the-scenes look at the code

  • A Among us programmer joins us to explain a key part of the game code.
  • This cross-platform game makes it seem easy to accommodate 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 like engine maintenance and repair. But for a player, the “small task” is to kill all the others. The game was released in 2018 but took off in 2020 as a board game that groups could play together virtually. It’s a fun game to start with, but it also illustrates some interesting things about how computer games are created and designed. We spoke with Shahrin Khan of Innersloth, the creators 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, from a main holding area. Once the match has started, up to three players are chosen to be imposters and the rest are regular players. This is an asymmetrical role-playing game, as Imposters have a different set of moves and abilities than the rest of the players. You might know popular asymmetrical horror survival games like Dead in broad daylight, where killers and survivors clash. In Among us, the crew members try to survive. The Imposter can travel through hidden vents, aiming to trap and kill players where others cannot see them. Then everyone gathers to vote on who they believe to be the imposters.

    Victoria T. (Innersloth)

    Why this game attracts users

    One of the great draws of Among us is that the game supports cross-platform play, which means people with the free Android app can join games with people on the Nintendo Switch, PC, and other consoles. The game is built in Unity, which is a game engine: the software that supports and underpins game development by including many existing features and libraries that developers are likely to use.

    First released in 2005, Unity was created as a Mac engine before supporting almost every other type of platform, from Linux to consoles. It’s even free for many users, as there’s a floor of $200,000 in annual earnings before an account upgrades to the paid version of Unity Pro, and developers who earn more than $200,000 per year are rare. Due to its philosophy of “democratization”, Unity also has a huge community of people who contribute resources that others can use in their projects. For small studios and individuals, this means saving time and money on creating assets such as character models and backgrounds.

    Programming languages ​​that work

    Unity uses C++ and C# programming languages. Coding is very generational and iterative, with languages ​​adding features and traits over time. C++ and C# trace 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 widely used; COBOL, popular for batch accounting and banking systems, dates back to 1959. There are probably others!)

    C++ is the backbone of much video game programming, in part because it was designed to interact with hardware in a power-efficient way. This means that software written in C++ can run more efficiently while taking advantage of computer hardware features such as graphics and RAM. C#, in turn, was supposedly 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 took it for that at first!)

    Let’s look at the code

    Khan writes code for Among us in an integrated development environment (IDE), software that makes it easier to view and work with code by using features such as color coding. We’ll have to do without it in this sample!

    shows a block of code that changes the color of a hat

    Inner laziness

    It’s a method, which is a block of code that only executes if someone else “calls” it. Calling SetHat(15) is like typing 15 into your calculator and then pressing the square root, except instead of the square root, the method changes the color of your hat. “It assumes that you already know who hat to wear, but the color changes,” says Khan. Color options are stored as integer values ​​because it’s much easier than asking the computer to analyze or interpret a color name written as a word.

    Then the code transforms the color code integer into something that performs the change in the Unity engine. This change actually applies the correct visual information to the art depicted in the game. doesn’t seem frozen – to load the ‘view data’ for the hat”, says Khan. “Once we loaded the texture, we finally used the color ID that was passed to us in order to color the hat appropriately.”

    among us programmer explain code snippet

    Victoria T. (Innersloth)

    Games, especially multiplayer online games, always balance many streams of information at the same time. And this is also true for most other uses of computing. We see all of our open applications or windows and think of them as separate streams all happening at once, but that’s because of programming staggering the “next step” of each process so that everything appears to be uniform. In reality, it’s more like strumming a guitar: technically, you strike one string at a time very close together, creating the sound of a chord.

    Among us has over 300 hats, and they are a big part of the game’s financial model. The Android app is free, and other versions of the game are quite inexpensive. but all players can pay for in-game currency which can be used to purchase themed cosmetic packs for seasons, holidays, and other special events. “The most fun thing about the hats personally is seeing all the pun-based names for them,” Khan says. “I really wanted to find a good pun to say that, but I couldn’t.” (A good pun is hard to top.)

    Hats are fun, but there’s a big downside, says Khan. “One of the challenges is memory management. Many older mobile devices cannot load too many in-game assets at once, which has led to crashing issues for some users. It’s something we need to be aware of whenever we add new cosmetics of any type, hat or not,” she says. And that makes sense, because the more complex a gaming experience becomes and the more art is used and managed during gameplay, the greater the strain on the computer’s CPU and memory that power the device.

    If ever a change were made to the SetHat method above, there is a very specific process to introduce the change to the code, and eventually to the players. Khan would make the change locally on his own machine and then test it. (Tests aren’t just one step or place in the process – half a dozen different types of tests exist, and some are used multiple times during development.) From there, new code would be loaded in files shared in Innersloth’s GitHub, an online service that tracks software changes and releases.

    “Every night we have an automated system that takes our working codebase and creates an executable or ‘build’ from it for various platforms like Steam, Android, etc.,” says Khan. “The next morning, these constructions will be ready for our [quality assurance (QA)] team to test it. If it passes their tests, the change is considered working and ready for the next update.

    Sometimes the changes are urgent, like new code that fixes an error that is crashing the game. Other times the code is for performance improvements, new features, or fixes for esoteric bugs and uncommon that do not have the same urgency. Development teams decide together when they want to schedule updated versions of their software. It can also be deployed at different times across platforms.

    Khan had some coding jobs before working on Among us, including six years as a Unity developer at a mobile game company. She says she was surprised at how cool the Innersloth team is, which is always a good thing in a job. “I think the main thing that surprised me was how great the team is and how much fun we all have working together,” she says. “It sounds very corny, but it’s true.”


    Comments are closed.