Deerstalker
A four-player online brawler where you knock each other off a construction site, using hats that grant special abilities.
About the Project
CSE 125 at UC San Diego is a ten-week capstone where a team builds a networked 3D game from scratch, with no game engine. Our team of seven was Team Deerstalker. The game went by "Rag Cage" on our team site and "Super Awesome Hat Attack Mania Wars" at the class showcase, and the pitch was simple: mysterious hats with great power have started showing up all over the world, so prove you're the true hat master in a last-one-standing brawl.
Four players start on a construction-site stage with three lives each. Fall off and you lose a life; the last player with lives left wins. Hats drop onto the middle of the stage every ten seconds or so, and each one gives you two abilities for as long as you wear it. The idea started as a four-person "pseudo wrestling" game with rag-doll fighting, and the hats were the hook from the very first design doc.
We split into a graphics and modeling sub-team and a networking and game-logic sub-team, and I was on the
second. I wrote the server and the networking: the game loop, the protobuf protocol, the Bullet physics world, the character
controller, all the combat and hat logic, the client's input and message handling, and the FMOD sound engine. By
git blame, about 88% of the server code is mine. The rest of the team built the skeletal animation
system and its ten character animations, the HUD and text rendering, the camera, skybox and cloud floor, and
the art (modeling, rigging and animating the characters, the stage and five hats), and wrote server pieces I built on or merged: the first server skeleton, the config loader,
item drops, respawning and shooting.
Objective
Knock the others off the stage; three lives each, last one standing wins
Hats
Five hats, each with a primary (RB) and a secondary (LB) ability
Multiplayer
Four clients over TCP; the match starts once all four press ready
Physics
One Bullet world on the server; clients only render what it sends
How It Works
The server owns everything. Clients never simulate anything. The server runs Boost.Asio on one thread to accept connections and read messages, and pushes every incoming message onto a mutex-protected queue. The main thread runs a fixed 30 Hz loop: drain the queue and apply each input event, step the Bullet world, expire mangoes and hats, update stun and respawn timers, then broadcast the result. Each tick advances Bullet by 1/15 s in four 1/60 s substeps, so the physics runs at double speed. We sped it up in week 8 because the game felt more natural that way.
What goes over the wire. Both directions use one protobuf
Message, framed as a 6-character ASCII length followed by the serialized bytes, over TCP with Nagle's
algorithm turned off. The header started at 4 digits and had to grow once snapshots passed 9,999 bytes. Clients send
intents: a direction from the stick (8 directions, read digitally at a 0.5 tilt threshold) plus the camera's facing
vector, or jump, punch, grab, equip, and the two hat buttons. Every tick the server answers with a full snapshot: for
every player, hat and mango, its 4x4 world matrix as 16 doubles, plus each player's health, lives, current hat,
animation state, visibility and hat timer. Alongside that come events for things clients should react to once:
sounds, deletions, ready/start, win and game over.
The client is a renderer. A background Asio thread parses snapshots into a queue; the render loop drains it each frame, creates scene-graph nodes for new IDs, and sets each node's matrix straight from the server. There is no prediction or interpolation. The server also decides which animation each player is in, and the client keeps a preloaded skinned model per animation and just shows the right one. FMOD plays sound effects in 3D at the position of the player or object involved, with the listener on your own player.
Movement. Players are dynamic rigid bodies with rotation locked off, driven by a controller adapted from the dynamic character controller in Bullet's old demos. Each substep it casts a short ray down to decide whether you're on the ground and a few rays forward to find punch, ram and wrench targets. A move event turns you toward the camera-relative direction and applies a force; a jump is an upward impulse that only fires when the down ray hits something.
Hold-to-use abilities with no state. At the start of every tick the server switches off zero gravity, invisibility and bear mode. The client sends a hat event every frame the bumper is held, which switches them back on. Holding the button keeps the ability on, and letting go ends it within one tick, without any timers or "is active" flags:
// Runs at the start of every server tick
void Game::loopReset() {
gravityController_->deactivate();
clearAnimations();
for (auto pair : playerMap_) {
pair.second->setVisible(true);
pair.second->setLinearFactor(btVector3(1,1,1));
pair.second->setBearMode(false);
}
} The Hats
Y picks up a hat within reach or throws yours away. A hat vanishes two minutes after it spawns, even on your head, and the HUD counts that down. When your health hits zero you're stunned for ten seconds and drop your hat.
๐ Bare hands (any time)
X punches: 10 damage and a knockback up and away. B grabs a stunned player within reach and carries them over your head; press B again to throw them.
๐ง Wizard hat
Primary: fire a mango that lives for two seconds. It does no damage, but it shoves whoever it hits.
Secondary: hold to heal.
๐ Propeller hat
Primary: hold to fly up.
Secondary: hold to push yourself down.
โ๏ธ Hard hat
Primary: a long-reach wrench swing that does 100 damage, so a hit stuns at once.
Secondary: a ground slam. Players standing within range take 10 damage and are pushed outward; loose hats nearby scatter.
๐ป Bear hat
Primary: hold to switch off gravity for every player (you too) while different music plays.
Secondary: hold to turn into a bear. You're rooted in place and take no damage.
๐ต๏ธ Deerstalker
Primary: hold to be invisible to everyone else.
Secondary: charge forward as a giant ram. Three rays, straight ahead and 60ยฐ to each side, find the target, which takes 20 damage and a bigger knockback than a punch or wrench hit.
Development Progress Videos
Development Gallery
Technology Stack
Client-Side
ASSIMP
Loads the OBJ, FBX and .X models, including the skeletal animations
OpenGL
GLSL 3.3 shaders, GPU skinning, a cubemap skybox and instanced clouds (with GLFW, GLEW, GLM, SOIL)
FMOD
Streamed music plus 3D sound effects, with the listener placed on your player
FreeType
Text for the HUD hat timer and the WINNER! banner
Server-Side
Bullet Physics
Bullet 2.83; the whole simulation runs on the server only
Shared
Protocol Buffers
One Message type both ways: input events up, world snapshots and events down
Boost.Asio
Async TCP on both ends with length-prefixed frames
C++
Visual Studio 2015 solution: client, server and a shared util library
Week by Week
My side of the project, from my weekly status reports and the commit log. The mood is the 1-10 morale score I gave each week.
- โธStarted from the Boost.Asio echo example and turned it into a server that broadcasts to every connected client
- โธMade the client read from its socket asynchronously and merged it with the graphics team's first renderer
- โธReplaced raw key-press messages with a Protocol Buffers schema for game events
- โธMade the server the source of truth: it runs the game loop and the only Bullet world, and clients just draw
- โธDisabled Nagle's algorithm on server sockets to fix the network
- โธAdded Xbox controller input through GLFW's joystick API
- โธLoaded collision shapes exported from Maya's Bullet plugin, starting with a compound rigid body for the mango
- โธHelped debug the camera and skybox and merged them in
- โธWorked on item spawning in Bullet and integrated the mango shooting
- โธBullet's kinematic character controller didn't work for us, so we turned to a dynamic (rigid-body) one
- โธBuilt out item interaction and game logic on the server
- โธFinished fixing message framing after world snapshots outgrew the original 4-digit length header
- โธWrote the dynamic character controller: ray casts for ground checks, movement relative to the camera
- โธMerged the respawn, equipping, throwing and shooting work and added the client side for it
- โธFixed several server-client bugs that came out of the merge
- โธSplit every hat into a primary and secondary ability, with one HatType enum shared by client and server
- โธBuilt the propeller hat and the wizard hat's mango shot, aimed from the player's rotation quaternion
- โธMoved client message handling out of the window code into a state-based MessageHandler
- โธSped up the physics simulation and moved character movement back to forces, which made the game feel much better
- โธPunching with a forward ray cast and knockback impulses; health sent to clients
- โธCapped the server at four clients with stable IDs 1-4, fixed spawn points and random hat spawns
- โธMoved animation-state decisions to the server and set up the FMOD sound engine
- โธBear hat gravity kill and deerstalker invisibility
- โธRamming, bear mode, stun, grabbing and throwing, the wrench hit and the shockwave
- โธ3D positional sound effects and the zero-gravity music
- โธLives with delayed respawn, a spectator camera once you are out, and the lobby to match to lobby loop
Problems I Ran Into
๐ฎ Character controller
Problem: Bullet's kinematic character controller has known issues, and it didn't work for us.
Fix: Players became ordinary rigid bodies with rotation locked, moved by forces, with ray casts for ground checks and attack targets.
๐ Framing and latency
Problem: The game's many small TCP messages didn't behave until Nagle's algorithm was off, and later the snapshots outgrew the 4-digit length header.
Fix: TCP_NODELAY on every server socket, a 6-digit header, and a 1 MB receive buffer.
๐งต Two threads, one game
Problem: Network callbacks and the game loop run on different threads.
Fix: Callbacks only enqueue messages, and the game loop owns all game state, so the only locks are on the message queues.
๐คผ Grabbing
Problem: Carrying a player who is also a physics body.
Fix: The grabbed player's linear motion is zeroed out and each substep their transform is pinned above and behind the grabber, rotated to lie flat. Releasing them restores physics and launches them as a projectile in the direction the grabber is facing.
Looking Back
Pin down gameplay early
The hat brawler idea never changed, but the actual gameplay wasn't settled until late in the quarter, and most of the hat abilities went in during the final two weeks.
Networking first
My advice in our final report was to get networking working early and make sure client and server can talk correctly at scale. With the server-authoritative loop in place by week 3, most later features were server logic plus a new field or event in the protocol.
Sub-teams worked
Splitting into a networking/game-engine team and a graphics team let both move in parallel, with weekly meetings for the big decisions.
From scratch
Building the engine ourselves is the point of the course, and I liked it: it's how you learn what a game engine actually does. For a game I just wanted to make, I'd reach for an engine like Unity and spend the time on gameplay instead.
