How We Built an FPS in ROBLOX
by Andrew Haak
The concept is familiar: up to 30 players join a game, and each player is randomly assigned to a team. Players contribute to their team’s score by taking out opponents and capturing control points. It’s a little like Team Fortress 2, but without the hats. We created Base Wars to show that an exciting first-person experience is possible in ROBLOX, as well as to give ROBLOX builders a resource they can draw upon for their own FPS creations. The source code for ROBLOX Base Wars is free, so download – or play – the most recent version here.
New Game, New Challenges
ROBLOX developers Deepak Chandrasekaran and Luke Weber built Base Wars using ROBLOX Studio, the same tool that ROBLOX players use to create games. Our developers encountered some challenges that had no solution in ROBLOX Lua and, in these cases, we added to the existing Lua functionality, which should help power users’ own FPSs in the future.
Traditionally, ROBLOX uses a third-person camera. We lobbied Ben Tkacheff to add support to the ROBLOX engine for a “force-first-person-camera mode”, so that players see from eye-level and can aim accurately. Base Wars uses the new Player.CameraMode property, set to “LockFirstPerson”, to make the first-person view happen.
Weber designed most of the weapons for Base Wars. He spent a fair amount of time experimenting with ways to reduce perceptible trigger lag on the guns. The solution we decided on was to use server-side raycasts for hit detection. We’ll flesh out the technical details of our implementation in a future blog post.
Base Wars uses character classes to encourage strategy and add replay value. There’s the basic, well-rounded Trooper, the nimble Assault class, the long-ranged Sniper, the damage-soaking Brute and healing Support class, each of which was play-tested time and again by the developers at ROBLOX. Testing Base Wars sounds like pure fun, our own little LAN party, but it was actually a tedious search for bugs and imbalances – a lot of work.
As Chandrasekaran said, “you can’t be sure it feels right until you sit down and play it.”
Above: Gameplay footage from Base Wars
Base Wars features a modified version of the capture points from our 2011 Halloween level, which we drew from one of Weber’s prior levels. Players gain control of them by holding their position for 10 seconds while in close proximity. Chandrasekaran and crew created four states for the capture point, each one indicating whether either team controls it in full or in part. There’s a lot of math going on behind the scenes, as controlling a capture point gives the controlling team points every five seconds, and the more teammates on a capture point, the faster you capture it.
The Content team dove into uncharted territory when it decided to add a custom leaderboard. The leaderboard was necessary because Base Wars is a competitive, score-driven game, and players need to know where they rank. The leaderboard constantly grabs data from the game server and updates with the latest player and team scores. Plus, the best player gets showcased at the end of the round.
If you look at the source code for the Base Wars leaderboard, you’ll see that, at the time of this post, we’re using a clever hack to crash the default ROBLOX leaderboard script and insert our own. (This trick was inspired by ROBLOX pro-scripter Quenty.) We’re working on a better, more official way to make specific CoreGui elements optional in the future.
Pressing “V” or “E” in Base Wars will bring up a minimap of the level, which will show, most importantly, which team controls which control points. Due to current limitations of our scripting API, this only works when your character has a weapon equipped. In the future, we’ll have a more elegant solution for this, too, which should benefit many scripters.
ROBLOX Base Wars is the Content Team’s first big project. We’re almost finished with version 1.0 and, from there, we plan to launch a new project in a completely different genre. What kind of content – strategy, role-playing, action – would you like to see from ROBLOX’s official developers in the future?