Building a 3D Fighting Game with AI Coding Tools: Characters, Combat Systems, and Combo Mechanics
This article documents a hands-on prototype of a 3D fighting game built with AI coding tools, covering character and stage generation, a state machine-driven combat system, juggle and combo-cancel mechanics, special move inputs, AI opponents with difficulty tiers, and match flow management. It also distills practical lessons on where AI tools excel (content generation) and where developers must lead (combat logic design).
1. Project Background and Goal Breakdown
I recently attempted to build a prototype of a 3D versus fighting game using AI coding tools. The overall experience can be summarized as: impressive static content generation, laborious dynamic system tuning. The tools performed brilliantly on the character showcase screen and stage construction—two distinct characters and a rainy rooftop stage came together almost in a single pass. But as soon as the match logic began, deep developer involvement in the design became necessary.
Before starting, I broke the goal down into a verifiable feature checklist:
- Characters and stage: two independently modeled characters, a rainy rooftop-themed stage;
- Battle modes: single player vs. AI (easy, standard, hard) and local two-player same-screen versus;
- Match flow: character select screen, best-of-three rounds, pause, and win/lose resolution;
- Combat mechanics: blocking, throws, jumping, dashing, launchers, and combo cancels;
- Advanced presentation: special moves triggered by directional input combinations, a super move at full meter with a cinematic cut-in.
This checklist is essentially a classic “simple presentation layer, complex logic layer” project—well suited to testing how AI coding tools actually handle complex state management.
2. Characters and Stage: What AI Excels At
Characters and environments are content-generation tasks, and the AI tools exceeded expectations. The reason is that these tasks are naturally well-structured: the model only needs to understand semantic tags like “female martial artist,” “costume color scheme,” “rain, night, rooftop railing” to produce usable 3D meshes, material textures, and lighting configurations.
Two practical principles:
- Give quantifiable constraints in your prompts. For example, specify character height proportions, polygon count limits, and rigging standards (such as a standard humanoid skeleton), so the tool doesn’t freelance its way into assets that are hard to reuse for animation later.
- Deliver stage and characters separately. The stage handles only visual atmosphere and collision boundaries; characters handle only skeletons, animations, and hitboxes. Combine them via mount points so you can easily swap stages or add characters later.
The rainy rooftop turned out well because “rain, night, rooftop” are all highly patterned visual elements: particle rain, volumetric light, and reflective floors all have mature implementation paradigms the tool can apply directly.
3. The Combat Core: The State Machine Is the Soul
Once I entered the match logic, difficulty spiked. A fighting game is essentially a high-real-time two-player state machine system—every character must be in exactly one well-defined state at any moment. A recommended state breakdown:
Idle / Walk / Dash / Jump / Attack / Block / Throw/ Hit (hitstun) / Airborne / KO
Core code skeleton:
const STATES = {IDLE: { canAct: true, cancels: ['walk','dash','jump','attack','block'] },ATTACK: { canAct: false, cancels: [], hitFrames: [5, 8], recover: 14 },BLOCK: { canAct: false, cancels: [], chipDamage: 0.1 },AIRBORNE:{ canAct: false, cancels: [], gravity: 0.6 }};function update(fighter, input) {const state = STATES[fighter.state];// Settle the current state's frame count first, then check cancel eligibilityif (fighter.frame < state.totalFrames && !canCancel(state, input)) return;const next = resolveTransition(state, input);fighter.transition(next);}
A few design rules to strictly follow:
- Frame data first: every action needs defined startup, active, and recovery frames. Hit detection only applies during active frames, and recovery frames are the defender’s punish window—this is the heart of fighting game feel.
- Hitstun overrides everything: the moment a character enters the Hit state, all buffered inputs are cleared, preventing “mash-through-anything” scenarios from breaking balance.
- Throws are non-hitting command grabs: they don’t participate in normal attack/defense resolution, but they must be avoidable by any state other than hitstun, and simultaneous throws from both sides cancel each other out.
4. Juggles and Combo Cancels: The Key to Game Feel
Juggle combos were the hardest part of the project to tune. Three implementation points:
- Gravity and bounce decay while airborne: when launched, the character enters Airborne; each ground bounce’s height decays by a coefficient, and once below a threshold, the character is forced into a knockdown, preventing infinite juggles.
- Cancel windows: allow specific attacks to cancel early into the next move when they connect during active frames. Use “cancel on hit” rather than “cancel anytime” to cap combo length.
- Combo counter and damage scaling: each hit within the same combo deals diminishing damage (e.g., ×0.85 per hit) so a single juggle can’t drain an entire health bar.
function applyDamage(combo) {const scale = Math.pow(0.85, combo.length);return baseDamage * scale;}
During parameter tuning, enable a frame-by-frame replay debug mode that records every match’s inputs and state transitions for inspection. Without it, many “the feel is off” problems are simply impossible to locate.
5. Special Moves and Meter Design
Special moves use the classic direction + button input: implement a time-windowed input buffer queue that collects the recent direction sequence over a few hundred milliseconds and fuzzy-matches it against a preset command table (e.g., “down, forward + punch”). Handle tolerance carefully—players’ diagonal inputs are often sloppy, so allow one noise direction to be inserted during matching.
Super moves require a full meter and trigger a cinematic cut-in on activation: pause world updates, push the camera in, play the character’s signature animation, then resume the match. Implementation-wise, build this as a standalone “theater mode” fully decoupled from combat logic, so frame events during the performance don’t pollute battle state.
6. AI Opponents and Difficulty Tiers
The AI doesn’t need real intelligence—it needs controllable uncertainty. The three difficulty tiers differ across three parameters:
- Reaction delay: easy reacts to player attacks only after 20+ frames; hard approaches the human limit of ~8 frames;
- Move pool: low-difficulty AI uses only a few basic attacks; high difficulty unlocks throw tech and punishes;
- Decision weights: the probability distributions for blocking under pressure and going for throws during blockstrings.
A simple weighted decision table is sufficient—resist the urge to build a deep learning model. Fighting game AI should aim to feel “human,” not “optimal.”
7. Match Flow and Resolution
Best-of-three rounds, pausing, and win/lose resolution are pure flow state management. A single top-level Match state machine (ROUND_START / FIGHTING / ROUND_END / MATCH_END / PAUSED) handles everything. When pausing, freeze all timers and animation clocks, and perform one frame alignment on resume.
8. Conclusion
The biggest takeaway from this project is one lesson: AI coding tools excel at generating content with clear, established patterns, but combat system design decisions must be developer-led. Once the state machine structure, frame data, and damage scaling rules are defined, the tool-generated code converges easily. Let the tool freelance the combat logic, though, and you’ll almost certainly end up with unmaintainable spaghetti code. Write the design doc first, have the AI implement against the doc, then hand-tune frame by frame—this three-way division of labor is currently the most reliable path for AI-assisted game development.
