3D Fighting Game Engine Architecture and Practical Design

    This article breaks down a layered engine architecture for 3D fighting games, explaining why projects that look polished in the main menu fall apart in actual matches. It covers a four-layer split (presentation, logic, decision, session), asset pipeline conventions for characters and stages, frame-data-driven combat logic with state machines and hit detection, three-tier AI difficulty based on decision quality rather than stat inflation, local versus session flow, and how presentation effects should subscribe to logic events without altering hit detection. Readers will get concrete pseudocode examples and design rules they can apply directly.

    1. Problem Framing: Why the Main Menu Impresses but the Match Breaks

    Many 3D fighting projects concentrate resources on the front end and character showcases early on: high-fidelity models, close-up cameras, dynamic lighting, strong visual impact. Once an actual match starts, problems surface all at once: frame rate collapses, hit detection drifts, combos cannot be canceled, and AI behavior feels stiff. The root cause is usually not art quality but missing engineering layers. The showcase layer and the combat layer share the same rendering and update logic, so the determinism, rollback capability, and low latency that combat requires are dragged down by expensive presentation techniques.

    The solution is to split the system into four layers: the presentation layer (models, animation, effects, camera), the logic layer (state machines, frame data, collision detection), the decision layer (player input and AI), and the session layer (rounds, score, pause, and results). These four layers communicate through explicit data contracts, and the presentation layer never writes logic state.

    2. Asset Pipeline for Characters and Stages

    Take two independently selectable characters and a rainy rooftop stage as an example. The asset side needs agreed conventions:

    • Consistent skeleton and naming conventions, so animations can be reused and the logic layer can read positions from skeleton attachment points;
    • Unified units (for example, 1 unit = 1 meter), avoiding a mismatch between logic-layer hitbox scale and the visual model;
    • Each action exports frame event annotations (active hit frames, cancel windows, hitstun frames); the logic layer only reads the annotations and never guesses animation progress;
    • The stage provides collision ground height, boundary values, and reflection/wetness material parameters for movement and camera use.

    An illustrative frame data description (pseudocode):

    1. action: heavy_kick
    2. frames: 26
    3. hitbox_active: [8, 12]
    4. cancel_window: [10, 18]
    5. hurtbox_state: standing
    6. pushback_on_hit: 0.35

    3. Combat Logic: State Machines Driven by Frame Data

    The combat layer should be pure logic with no rendering dependency, advancing at a fixed step (for example, 60Hz) so results stay consistent across machines.

    1. Character state machine: idle, walk, jump, crouch, block, hitstun, throw, dash, juggle, knockdown, wake-up. Each state defines entry conditions, interruptible conditions, and exit frames.
    2. Detection system: hitboxes and hurtboxes are intersected every frame; on a hit, conflicts are resolved by priority (throw > super > special > normal).
    3. Combos and cancels: entering the next action is allowed only within the cancel_window and only when the previous move has connected, preventing “whiff into a move” from breaking balance.
    4. Blocking and juggling: blocking must distinguish standing block from crouching block, plus a guard-break value; the juggle state provides gravity and a hittable window, and landing transitions into knockdown frames.
    1. if hit_conflict:
    2. resolve_by_priority(move_priority)
    3. if now in cancel_window and last_move_hit:
    4. allow_cancel(next_move)

    4. AI Decision-Making: Three Difficulty Tiers, Not Stat Cheating

    For single-player against AI, the best practice for three difficulty tiers is not simply inflating damage or health, but changing decision quality:

    • Easy: longer reaction delay, fewer combos, higher rate of dropping guard;
    • Normal: uses directional special moves, actively creates distance;
    • Hard: recognizes player habit frames, chains reliably inside cancel windows, manages resources more sensibly.

    The AI runs a “perceive-evaluate-select-execute” loop. The perception layer only reads the public match snapshot from the logic layer (distance, opponent state, resources), and the execution layer produces virtual commands identical in form to player input, keeping behavior fair and reproducible.

    5. Local Versus and Session Flow

    Local versus play needs isolated input mapping, mutually exclusive character selection, a best-of-three round state machine, and freezing of the logic layer and timers while paused. The results phase outputs the winner, combo statistics, and key-frame replay data. Making the session layer an explicit state graph is recommended:

    1. select -> round_intro -> fight -> round_end -> (fight | match_end)
    2. pause: freeze(logic, timer) / resume

    6. Presentation Layer: Wiring Close-Up Cameras and Effects Correctly

    Close-up cameras, hit stop, and screen shake belong to the presentation layer and may only subscribe to logic-layer events (such as on_hit, on_super_finish); they must never modify detection in reverse. This way a close-up can be inserted on a super move without presentation jitter causing inconsistent hit detection. If multiplayer online is needed later, the logic layer’s determinism and event-driven design can be reused directly for state synchronization and rollback, while general cloud capabilities such as object storage, message queues, container platforms, logging services, and monitoring/alerting can respectively handle asset distribution, room messaging, service elasticity, troubleshooting, and production observability. Baidu AI Cloud can provide support in these general categories, but actual integration should still be evaluated against the real architecture.