Designing a Core Combat System for a 3D Fighting Game: Architecture, Input, and AI

    A practical guide to building the core combat system of a 3D fighting game, covering logic/rendering separation, fixed timestep simulation, input buffering with special move detection, data-driven state machines, tiered AI difficulty, and flow control from character select to match settlement.

    Designing a Core Combat System for a 3D Fighting Game: Architecture, Input, and AI

    The Problem: A Gap Between Presentation and Combat

    In many 3D fighting games, the character select screen looks polished: models, idle animations, stage atmosphere, and UI effects are all well finished. But once the actual fight begins, the experience clearly degrades — unstable input response, jarring camera cuts, choppy character state transitions, shallow AI behavior, unreliable special move recognition, and messy pause and settlement flows.

    These issues usually stem not from any single screen but from a missing set of shared engineering constraints between the presentation layer and the combat layer. The character select screen is largely “presentation-driven,” while the battle screen is a composite system of logic, presentation, and input. Without clear layering, a fixed timestep, input buffering, state machines, and data-driven configuration, the polish of the select screen cannot naturally carry over into combat.

    This article walks through the full pipeline from character select to match settlement and discusses how to design and implement a 3D fighting game’s core systems.

    Overall Architecture: Separating Logic, Presentation, Data, and Flow

    The system should be split into four layers:

    1. Combat logic layer: Handles character states, frame data, collision detection, damage resolution, meter, and round/match outcomes. It should advance on a fixed timestep to guarantee consistent hit detection across devices.
    2. Presentation layer: Handles animations, VFX, camera, UI, audio, and cinematic close-ups. The presentation layer only consumes events from the logic layer and never influences combat outcomes.
    3. Data configuration layer: Character stats, move frame data, cancel rules, AI parameters, stage boundaries, and round rules should all be driven by configuration tables rather than hardcoded.
    4. Flow layer: Character select, loading, battle, pause, round settlement, match settlement, and returning to select. The flow layer is decoupled from combat; pausing freezes only the combat logic, not menu rendering.

    A simplified battle loop:

    1. interface BattleContext {
    2. frame: number;
    3. fighters: Fighter[];
    4. stage: Stage;
    5. roundState: "ready" | "fighting" | "roundEnd" | "matchEnd";
    6. }
    7. function fixedStep(ctx: BattleContext, inputs: InputFrame[]): BattleEvent[] {
    8. const events: BattleEvent[] = [];
    9. for (const fighter of ctx.fighters) {
    10. fighter.input = resolveInput(fighter.id, inputs);
    11. fighter.stateMachine.update(fighter, ctx, events);
    12. }
    13. resolveCollisions(ctx, events);
    14. resolveDamage(ctx, events);
    15. updateRoundState(ctx, events);
    16. ctx.frame++;
    17. return events;
    18. }

    The key to a fixed timestep is separating the simulation frame rate from the render frame rate. The renderer can interpolate, but hit detection must advance on fixed frames. Otherwise, high-refresh-rate and low-refresh-rate devices will see different combo windows, block timing, and throw detection.

    Character Select and Local Two-Player Flow

    The character select screen should output a stable “battle configuration,” not just a model ID. The configuration should include at minimum: character ID, move list, initial meter, input device slot, color palette, and stage binding. When two fighters enter battle, the system should bind each to its own input device rather than sharing input state.

    Local versus play requires handling device slot mapping, button conflicts, pause permissions, and round settlement attribution. A suggested flow state machine:

    1. type MatchState =
    2. | "select"
    3. | "loading"
    4. | "roundReady"
    5. | "fighting"
    6. | "paused"
    7. | "roundEnd"
    8. | "matchEnd";
    9. interface MatchFlow {
    10. state: MatchState;
    11. round: number;
    12. wins: [number, number];
    13. maxRound: number;
    14. }

    Best-of-three rules belong in the flow layer, not inside the character state machine. After each round, the flow layer records the winner, resets fighter positions and meter strategy, then starts the next round. Pausing only switches the flow state: combat logic stops advancing while UI and menus stay responsive. This prevents pauses from losing animation events or polluting the input buffer.

    Input System: Buffering, Direction Combinations, and Special Move Detection

    Fighting games demand high input tolerance. A recommended approach is “input sampling + ring buffer + pattern matching”:

    • Record direction and button states every logic frame;
    • Keep input history for a fixed window;
    • Normalize directions and apply debouncing;
    • Match special moves against direction sequences and button combinations;
    • Consume input immediately on a successful match to avoid repeated triggers.
    1. interface InputFrame {
    2. frame: number;
    3. dir: "N" | "F" | "B" | "U" | "D" | "DF" | "DB" | "UF" | "UB";
    4. buttons: string[];
    5. }
    6. class InputBuffer {
    7. private history: InputFrame[] = [];
    8. private window = 12;
    9. push(frame: InputFrame) {
    10. this.history.push(frame);
    11. if (this.history.length > this.window) this.history.shift();
    12. }
    13. match(pattern: Array<{ dir?: string; button?: string }>): boolean {
    14. let index = 0;
    15. for (const frame of this.history) {
    16. const expect = pattern[index];
    17. const dirOk = !expect.dir || expect.dir === frame.dir;
    18. const btnOk = !expect.button || frame.buttons.includes(expect.button);
    19. if (dirOk && btnOk) index++;
    20. if (index === pattern.length) return true;
    21. }
    22. return false;
    23. }
    24. }

    For directional special moves, the critical factors are “window” and “priority.” A shorter window is more hardcore; a longer one is more forgiving. When multiple moves conflict, filter by priority and current state. Dash, jump, and block should also support pre-input buffering so commands entered just as recovery ends aren’t swallowed.

    Character State Machine and Combat Rules

    The fighter state machine should cover: idle, walk, dash, jump, block, hit, throw, airborne, grounded/knockdown, special, super, and KO. Every state should define entry conditions, exit conditions, cancelable moves, and animation events.

    1. type FighterState =
    2. | "idle" | "walk" | "dash" | "jump" | "block"
    3. | "hit" | "throw" | "airborne" | "ko";
    4. interface MoveData {
    5. id: string;
    6. startup: number;
    7. active: number;
    8. recovery: number;
    9. cancelInto: string[];
    10. damage: number;
    11. }
    12. function canCancel(current: MoveData, next: MoveData, hitConfirmed: boolean): boolean {
    13. if (!current.cancelInto.includes(next.id)) return false;
    14. return hitConfirmed || next.id === "dash";
    15. }

    Blocking, throws, jumps, dashes, juggle states, and combo cancels should be described in data tables rather than scattered across condition branches. Combo cancels should distinguish “hit cancel,” “block cancel,” and “landing cancel,” paired with damage scaling to prevent infinite combos. Airborne states need dedicated handling for gravity, air hits, landing recovery, and teching rules.

    Three AI Difficulty Tiers: Explainable Behavior Parameters

    For single-player AI, design three tiers — easy, standard, hard — but don’t just tune damage or health. A better approach is to adjust decision parameters:

    • Reaction delay: Time from an input event to the AI’s response;
    • Decision interval: How often the AI re-evaluates its behavior;
    • Defensive tendency: Weights for blocking, countering, or retreating when under attack;
    • Combo length: The complexity of combos the AI is allowed to execute;
    • Resource usage: Tendency to spend meter on supers when full;
    • Spacing: Strategy weights for approaching, zoning, and jump-ins.

    Implementation can use a finite state machine plus a behavior weight table. The easy tier reduces reactions and combos; the standard tier adds blocking and punish attempts; the hard tier improves hit confirmation and meter efficiency — while still keeping a readable attack-defense rhythm.

    Supers and Cinematic Cameras: Separating Logic from Presentation

    Full-meter supers with cinematic close-ups can easily break combat consistency. The recommended pattern: the logic layer only emits a “super start” event, and the presentation layer plays camera tracks, masks, VFX, and time scaling. During the cutscene, lock inputs, set invincibility frames and damage-detection windows, and restore logical state via a callback when the presentation ends.

    Cinematic cameras need clear camera bounds and stage adaptation. For example, a rainy rooftop stage requires handling ground reflections, rain particles, distant-geometry occlusion, and camera clamping. Presentation assets should be preloaded to avoid hitches on first trigger.

    Performance and Experience Optimization

    1. Asset preloading: After character select, preload battle models, move VFX, stages, and UI assets.
    2. Object pooling: Reuse hit effects, rain particles, damage numbers, and audio instances.
    3. Animation/logic decoupling: Hit detection follows frame data; animation is purely presentation interpolation.
    4. Camera stability: Define camera bounds, smooth follow, and cinematic priority to avoid camera jitter.
    5. Input latency monitoring: Log frames from input to state change and include it in acceptance criteria.
    6. Frame-level replay: Save input sequences and random seeds to reproduce combo, AI, and settlement issues.

    Testing and Acceptance

    Acceptance should cover: character select to loading, single-player against all three AI tiers, local versus play, best-of-three, pause/resume, win/loss settlement, special move input recognition, and super cinematic regression. Test cases should include frame-level replays with fixed input sequences, verifying that hit frames, damage, meter, and round states are consistent.

    In short, improving a 3D fighting game’s experience should not stop at the character showcase. Build the complete pipeline of “fixed logic timestep + input buffering + data-driven state machines + layered flow + event-driven presentation.” Only when the presentation and combat layers share the same engineering constraints can the polish of the character select screen carry through to actual matches.