ZombiesWithGuns.io is a multiplayer first person shooter made with Babylon v4 (NullEngine) and nengi.js (a recently open sourced network engine). Hopefully there are some players in there when you try it!
Players can change their keybinds in-game, but the defaults are:
- WASD: move
- mouse: look around
- left click: shoot
- right click: aim down sights (reduces recoil/bloom, zooms if sniper)
- shift: sprint
- spacebar: jump
You may also sign in with google/facebook to have the game save long term stats and add your scores to the daily/weekly leaderboards.
Technical details for you devs:
- the game map is 9 large meshes, made in MagicaVoxel
- server is a Vultr VC2 8192 ($40), and runs 24 instances of the game
- each game instance holds up to 10 players (for design reasons…actual max is way higher)
- runs on some (many?) chromebooks/low-end devices
- server is 20 ticks per second
- client uses predictive netcode, and flexible rates (30-250 fps all are playable)
- netcode allows shooting right at the target at a variety of latencies
- all shots are calculated on the server, not the client!!
- collisions are regular babylon raycasts + a homemade voxel engine
- webpage and in-game hud, ui, and menus are Vuex+VueJS
- every player body part is a separate mesh, programmatically animated
- each body part has its own hitbox…but i’m in the process of changing that (hands and forearms are immune/weird at the moment)
I’ve been obsessed with network programming for several years (I love multiplayer) and I had been developing nengi.js, primarily pairing it with Pixi. Nengi could hypothetically network anything from an mmorpg to a first person shooter – but that latter one hadn’t been proven. There is a game that is kinda close, Bruh.io. It has the type of netcode you’d find in a first person shooter (predicted movement, compensated shots, etc) but ultimately it was still a top down 2D game.
So as you could imagine I was excited to hear about NullEngine. I write server-authoritative games. That’s a programming model where the game client is heavily distrusted due to hacks and cheats. The technique to reduce cheating involves being able to perform an action on the client (such as moving or shooting) and being able to deterministically replicate that exact same thing on the server. The client version of this action is somewhat fake and might not be accepted by the server – it exists to provide visual feedback to the player and make the game feel like it has no latency. But the action that actually affects the game world as seen by everyone else is the version that occurs on the server. NullEngine makes this determinism much more obtainable… We can fire a shot on a game client… and then calculate two identical rays one on the client and one on the server. What does the client ray do…? Well for ZWG it just draws that tracer/smoke trail thing and eventually I’ll add a blood effect. Meanwhile an identical server ray is used to actually deal damage. This core technique is the basis of so much!
I did run into some issues with collisions and animations for which I made some very questionable decisions. Since nengi is now open source, and babylon was always open source, I imagine some people would like to see some game templates showing the two working together. This game makes it look like the two get along fantastically…and for the most part that is true. However I wrote a collision system that uses voxels. I also performed every animation programmatically! These are kinda large problems that need solved. I should probably write about these in the forum and try to come to some solutions, esp. if there is particular interest in nengi+babylon integration. I mean why not, right?
Edit: here’s a game play vid: