Kaiju Defense Club experiment 0
The “Experiment 0” version of Kaiju Defense Club is out today!
Click to play! (PC only - mobile coming soon)
Kaiju Defense Club
Kaiju Defense Club is an online multiplayer arcade game where you and your crew battle waves of giant monsters and grab their resources to power up your mech (and score big points!)
The initial “Asteroid Mining” mode is a time attack mode where you fight waves of enemies, use your turret arm to scoop up resources that unlock upgrade abilities and rack up points.
You can send invite links from the lobby screen to bring other players into your game! Up to four players can play at a time, but more players can join and watch.
We’d love to see your high scores! Share them in the 2weeks Fun Club Discord server.
Where it could go
In a full version of Kaiju Defense Club, Asteroid Mining would be an introductory mode to teach you the core mechanics of the game (and that you can return to as you build mastery to rack up high scores!)
The planned primary mode is City Defense, where waves of Kaiju (including sub-bosses and bosses) attack a city and you and your crew deploy to repel the invaders.
Here’s our draft intro narrative:
Space exploration led us to discovering alien entities in the asteroid belt powered by cores with incredible energy.
We’ve harvested those cores and brought them back to Earth, and it has completely transformed society. But the entities have followed us, and will stop at nothing to reclaim their energy cores.
Much of society has marshalled around harvesting energy cores and defending our new techno-utopia. You’re a high school student at the beginning of your Kaiju Defense career.
Your club only has access to hand-me-down equipment, but you can still do your part for Kaiju Defense and make a name for yourself as a Kaiju Defense Pilot.
Good luck, pilot! Your planet is counting on you!
Experimental hypothesis
The genesis of Kaiju Defense Club was admiration for Discord’s new Activities. Foge and I boot up a Discord Activity every morning before we start our daily checkin.
For us, it harkens back to getting quality hangout time playing arcade games together - our early friendship was forged around an arcade cabinet at the ArenaNet offices, and Discord Activities seem like such a great format to get that same kind of experience in an online community.
We’d love to deploy all of our games as Discord Activities as the platform opens up, but we wanted to take a swing at a specific experience tailor-made to the format.
Kaiju Defense Club has a lot of influences, including games like Rampart and Geometry Wars, but we were excited about building something with simple one-button controls and great game feel. We’d love your feedback on how we did and where you think we could go with it!
Technical investment
This was also an opportunity to build out our multiplayer tech. Kaiju Defense Club sits on top of newly built multiplayer tech for the Tweaks engine. It’s optimized for making it easy for friends to connect together over the web by simply sending web links to each other wherever they’re already communicating.
For folks who are interested in the technical details:
- We’ve built a session manager on top of Cloudflare Workers that helps players establish peer-to-peer connections. The clients connect to the service via WebSockets.
- Peer connections are managed via WebRTC, with the session server helping with the signaling steps and connecting players through a TURN service if a direct connection isn’t possible.
- We’ve written a lightweight data replication module for our Lua scripts that make it easy for the host to mirror gameplay state to all the participants.
- Kaiju Defense Club uses deterministic lockstep networking. The host gathers all player inputs and broadcasts them back to everyone so that each participant can run the simulation with identical inputs.
The infrastructure is early (and you may encounter bugs!). There are a few improvements we’d like to make over time:
- The session service doesn’t yet support host migration. Right now, if the host leaves the session, the session terminates.
- The lockstep solution is relatively naive and latency-sensitive. The gold standard for deterministic simulation is lockstep with rollback, which allows you to predict future inputs and roll back state when you mispredict, allowing you to hide a lot of latency. We don’t have a rollback solution, so you may experience high latency if you’re far away from the host. If you’re interested in learning more about rollback, GGPO is a great open source library for implementing lockstep with rollback and they’ve got good articles explaining the technique on their website.
- The engine isn’t yet reliably deterministic. We have to be careful to avoid features that might be sources of nondeterminism, including low-level Lua details like tables not guaranteeing deterministic iteration order by default. We’ll likely have to make some changes to both the Lua runtime and our modules to make it more foolproof. Fortunately, there’s prior art here. Factorio is Lua-based and has deterministic multiplayer, and they’ve kindly published their modified version of the Lua runtime - it’s for a different version of Lua than we’re using but it’s helpful reference for performing similar modifications.