Cockfights Online
A direct-control 3D bird fighting game that became an experiment in movement feel, readable physical combat, character presentation, network authority and making a game practical to deliver in a browser. The most interesting work lives between systems: a hit changes momentum, animation explains it, the camera keeps it readable, and the HUD leaves room to play.
A small fighting game with a broad engineering surface
Cockfights Online is played directly, from behind a bird in a three-dimensional arena. Movement, aim, spacing and the timing of a kick belong to the player. The game uses Unity, C#, CharacterController collision, the Input System and editable ScriptableObject tuning. That makes it a useful meeting point between programming and visual work: the code has to make a bird controllable, but the animation, arena and interface also have to explain what is happening.
Start a quick match against a CPU rival, choose a bird, opponent and difficulty, then enter one of six arena layouts. Training isolates individual actions; the story circuit introduces different opponent styles. Movement, jumps, pecks and kicks all feed into the same playable browser experience.
The aspiration was to explore the whole chain from a character idea to a playable, inspectable build. The case study therefore follows the boundaries between systems rather than treating a long feature list as the achievement. A camera that cannot see around a wall, a hit effect that changes gameplay timing, or a menu that covers the fighter can undermine otherwise working code. Much of the learning is in making those pieces agree.


Controls are a contract with the simulation
The current source binds WASD to movement, mouse motion to camera/aim, Shift to sprint, Space to jump or a valid wall interaction, and C to crouch or slide. Peck is left-click or J; kick is right-click after pointer capture or K. F guards, Q sidesteps, G shoves and E invokes the class special when enough focus is available. Escape releases capture and opens the pause flow. Those keyboard alternatives were useful during the local browser capture because they exercise the same action rules without inventing a separate demonstration controller.
CombatInput converts device events into a CombatIntent rather than allowing each input device to manipulate health or movement directly. It keeps a pending action until the physics update consumes it and gives simultaneous action edges a defined priority. It also distinguishes the click that captures the pointer from a real kick. That is a small browser-specific detail with a large effect on whether the game feels trustworthy.
Attacks have startup, active and recovery phases. A heavy kick commits the bird's attack direction; a clean light hit can open a short follow-up window, while an airborne kick leaves a landing obligation. The interesting lesson is that responsive input does not require every action to be immediately cancellable. Buffering and explicit commitments let a player express an intention while keeping the opponent able to read and punish it.

Four starter styles, one underlying ruleset
The combat styles include Rookie Rooster, Dust Runner, Peck Brawler and Sky Dart. Rookie is the steady counterfighter with relatively quick recovery. Dust Runner moves faster and commits to rushing kicks, trading away guard strength and accepting longer punishment windows. Peck Brawler is slower and shorter-ranged, with stronger close pressure from pecks and shoves. Sky Dart emphasizes the aerial kick, then pays for it through a more vulnerable landing. These are source-defined mechanical differences, not merely differently colored models.
The style system preserves the combatant's original values before applying a complete style-owned baseline. Switching away restores those values, then applies the new style. A ConditionalWeakTable associates the original tuning with that combat instance. This avoids a subtle state problem: choosing Brawler after Dust should not leave some Dust values behind or mutate a shared tuning asset that affects the other fighter.
Movement style is similarly expressed as a multiplier over the shared walk/sprint tuning. The advanced movement panel can retain a meaningful common baseline while the selected bird has a different pace. The learning topic is data ownership: a shared asset describes common controls, a style owns a limited group of numbers, and a fighter instance owns its current state. The local Roost also displays an additional Ruckus card; this is recorded as a local-build observation rather than silently added to the four-style source description.

Making momentum readable and controllable
BirdMotor keeps movement state separate from the character's animation. It tracks horizontal velocity, vertical motion, ground samples, buffered jumps, slide timers, vault endpoints and wall-kick state. The presenter reads those results; it does not decide how far the controller travels. That separation matters when a visual animation is swapped or blended: the character can keep the same collision and input rules.
Ground turns have explicit momentum-retention anchors. A straight run preserves speed, a reversal loses it, and intermediate changes interpolate between configured values. The motor applies that directional cost when the intended world direction changes, then resumes ordinary acceleration. The code compares actual carried velocity as well as intent, so releasing a key, colliding and pressing again does not automatically evade the cost. Air steering, sliding friction, slide steering and acceleration remain independent controls rather than one all-purpose speed value.
Jump buffering and coyote time soften timing at the edge of footing. Sliding can be queued for landing; a fresh jump near a suitable wall can push away once per airtime. Traversal and running-kick readiness are coordinated so a buffered jump does not accidentally become an attack variant. The in-game tuning panel exposes these variables beside the live scene. For a learning project, that is particularly useful: a movement hypothesis can be changed and observed without changing character art or hiding the result behind an animation clip.


The camera is part of the collision problem
A follow camera can be mathematically correct and still make a fight unreadable. FollowCamera checks whether its starting volume is already overlapping scenery before using a sphere cast, because a cast alone cannot reliably report an initial overlap. If the usual boom is obstructed, it searches a shallow orbit upward around the subject instead of simply lifting the camera without preserving its view of the bird.
The response into an obstruction is immediate; the return toward the desired distance is damped. Crucially, intermediate positions are checked again, so smoothing is not allowed to send the camera through a corner. Small landing-height changes are filtered while horizontal tracking remains direct. The visible jump capture shows why that matters: the player can move into the air near the shed and scenery still frames the body and the ground beneath it.
Contact recoil is an additive presentation offset. It is not fed back into the accepted aiming direction, so visual impact does not slowly rotate the player's controls. The finish camera uses real-time motion while simulation slows down, chooses a side with room, and restores the prior time scale and fixed step when it ends or is disabled. Reduced motion suppresses contact impulses and steadies the finishing shot. These are concrete examples of treating camera polish as stateful engineering rather than an unbounded collection of shakes.

An impact has to mean the same thing everywhere
The combat model distinguishes light contact, heavy kicks, sweeps, shoves and running kicks. Attack phases, queued actions, cancel windows and cooldowns are advanced by a common simulation clock. That reduces the risk that a coarse update changes the meaning of a short active window or expires a buffered action differently from its hit sweep. A struck bird can still receive limited reaction steering, while knockdown and landing obligations have their own restrictions.
CombatImpactBatch gathers contacts for a simulation substep, prepares defenses, aggregates outcomes and applies them before publishing presentation callbacks. The stated invariant is practical: one fighter's already-earned contact should not disappear merely because the other impact is processed first and cancels an attack. Contact records carry the accepted point, normal, actual damage, block result and resolution identity. Animation and sound can respond to that event instead of guessing that a nearby swing must have hit.
The current tactics source adds a focus resource: it starts at 25, a special costs 60, and escaping pressure costs 40. A newly timed guard can open a short counter opportunity, while a shove pressures passive guarding. Those rules introduce choices beyond repeating the largest attack. The capture demonstrates real input and action presentation, not a balancing result: training remained at 0/3 after the photographed peck attempts, so no successful drill completion is claimed.
Weight comes from coordinated feedback, not only damage
The repository's evolution explicitly calls out heavier launch tiers, grounded hit pops, pursuit feedback and restored head follow-through. Those changes connect a contact's consequence to what a player sees next: the opponent moves, the bird reacts, the camera acknowledges it and the player has room to pursue. A health subtraction alone would communicate much less about the difference between a peck and a committed kick.
RosterBirdPresenter builds a playable animation graph and reads simulation state to blend clips. CombatFeedback describes itself as presentation that does not rotate the controller or change simulation time. PhysicalCombatFeedback computes a quick fall, readable knockdown hold and deliberate return, while reduced-motion checks limit optional visual treatment. The distinction is important: animation can exaggerate a reaction without silently changing the hit test or the controller's authority over position.
Sound is another programmable material. PhysicalCombatFeedback can synthesize a transient, low body resonance and filtered rustle into an impact clip with bounded headroom. GameAudio observes match and movement events and has separate effects, music and ambience controls. The lesson is to make several small signals reinforce one accepted event, while keeping them observers of the game. That makes a style or presentation change less likely to alter the rules accidentally.

Practice, drills and a circuit teach different things
Practice lets the player choose bird, rival, difficulty and arena without needing a progression reward. The opponent uses the same CombatIntent interface as the player. Its decisions observe public combat state at a reaction interval, rather than deciding every action on every rendering frame. Recent attack and guard queues let it react to habits: repeated sweeps can invite a jump, repeated heavy attacks can prompt spacing, and guarding can be pressured with a shove. This is inspectable rules-based adaptation, not a claim of a trained machine-learning opponent.
Training narrows that surface to movement, peck, guard and evade drills. TrainingSession subscribes to accepted combat events and tracks actual horizontal travel. A peck counts only when the opponent receives an unblocked, non-heavy, non-shove contact from the player. A guard drill counts a blocked opponent hit; the movement drill accumulates measured travel. Reset and health recovery logic keep the drill usable after mistakes. The screenshot's 0/3 readout is meaningful because it is tied to those events, rather than counting button presses.
The three-stage circuit changes the tactical problem. Bramble is balanced in the Backyard, Dust Devil is aggressive in the Badlands, and The Warden is defensive in the Roost Dome. Their instructions point toward reading windups, escaping a missed kick and pressuring a guard. LocalProfile records completed encounters and first-time rewards. It is a compact way to explore progression without claiming a large campaign or equating an offline profile with the online economy.



Arenas carry both an atmosphere and a movement problem
ArenaCatalog defines six spaces with different layouts and lighting. Backyard uses close brawls, timber and a porch. Badlands provides longer chases, rock flanks and a raised ledge. Rooftop Rumble uses ramps and upper roofs; Roost Dome is an open championship oval. Jungle Ruins breaks sightlines around walls and a temple terrace, while Neon Pit compresses pressure into equipment lanes and a raised stage. These descriptions make the connection between environment art and the movement/combat system explicit.
Blender scripts assemble arena layouts and export them into Unity. Import helpers connect the character and arena assets to the playable build. Keeping editable source art separate from exported meshes makes iteration possible without treating a game export as the only copy of the work.
The WebGL delivery path adds another layer: authored prefabs remain ordinary editable meshes, while a build transaction temporarily substitutes packed geometry. PackedArenaMeshes reconstructs render and collision meshes at runtime. The decoder checks counts, flags, indices, truncated data and unexpected trailing bytes. Art therefore becomes a data-format problem as well as a visual one, with the collision representation needing to stay dependable after packaging.

Online play needs a different authority boundary
The online code does not ask a client to report that it won an exchange. OnlineCommand carries movement, aim, held controls and an action with a match identity and sequence. The authoritative arena owns motors and combatants, and the server advances a fixed 1/60-second step. The server sends snapshots every third tick, keeping simulation cadence separate from update delivery. Session limits, packet-size checks, packet-rate checks and bounded outgoing queues are visible in source.
The client predicts movement, retains pending commands, accepts a newer matching snapshot, removes acknowledged commands and replays the remaining movement steps. BirdMotor.Network serializes more than position: velocity, facing, vault endpoints, slide state, jump-related timers and ground validity travel with the state. That is why separating input, motor state and presentation pays off. A visual snap alone would not restore the conditions needed for the next movement step to behave consistently.
Mode definitions cover casual and ranked duels, team play, free-for-all and hill scoring, plus configurable friend-room options. AccountClient describes revisioned cloud settings, equipment, currency, shop and season requests; a dedicated-server gateway validates identity and records results. The client requires an acceptable HTTPS endpoint except for an explicit loopback-development allowance. These are inspected implementation boundaries. The offline browser capture intentionally does not connect a second player, sign in, submit results or establish that any live service is operational.

The interface iteration started with the fight being obscured
The October 30 design record makes the problem concrete: health cards and the move bar covered the player's bird, and the home screen offered too many equally loud actions. The owner-approved direction borrows patterns that solve analogous problems—compact live-score displays, edge-positioned workout controls, a single primary play action and art-led browsing—rather than treating a visual reference as an instruction to copy an entire unrelated app.
The resulting HUD puts player and rival health at the top, with the timer and round information between them. Move cues stay at the lower edge and the pointer-capture prompt has its own position. In the actual local jump and movement captures, the body and most of the centre remain visible. Menu screens share a plain-text navigation strip and large art cards. The project stays in Unity UI Toolkit with C# trees and USS instead of introducing a second UI technology for the redesign.
Settings include text scale, reduced motion, control hints, sensitivity, sound channels and resolution limits. Keyboard and gamepad navigation let players move through the menus without relying on a mouse.

The browser build is an engineering target of its own
The release builder selects size-oriented IL2CPP generation, high managed stripping, disk-size WebAssembly optimization and engine-code stripping. A release download gate counts export files instead of assuming that a warmed browser cache makes a large build acceptable. Character import optimization retains the model/animation content while adjusting compression settings. Arena packing is transactional: recovery metadata and disposal restore normal authoring assets after the temporary build substitutions, including recovery from a stale interrupted transaction.
Browser delivery adds a practical constraint: every asset has to download before it can be used. A release size budget makes textures, meshes, audio and packaging part of the design process, alongside the game itself.
Checks cover gameplay, menus and the HUD, with browser play sessions helping catch problems that automated checks can miss. The playable local build and its screenshots show the game’s movement, combat and interface; they do not depend on signing into an online account.