3D Fighting Game Engine Architecture and Combat System Design Practices
This article explains how to build a complete and extensible 3D fighting combat system using a general-purpose technology stack. It covers a five-layer architecture that decouples logic from rendering, frame-data-driven state machines, input buffering for directional command moves, three-tier AI difficulty, local versus play and round management, and a performance and debugging checklist. The goal is to avoid the common pitfall where the main menu looks impressive but the actual fights feel broken.
1. Background: Why “Great Main Menu, Broken Combat” Is the Norm
In early prototypes of 3D fighting projects, a common pattern appears: the main menu character showcase and stage atmosphere look polished, but as soon as the actual match begins, the feel, hit detection, and pacing collapse quickly. The cause is usually not art quality but missing engineering structure: combat logic is coupled with the presentation layer, state transitions lack frame-data constraints, input sampling is not synchronized with logic frames, and collision bodies are not synchronized with animations. Using the neutral example of a “warship” as a starting point, this article discusses how to build a complete, extensible 3D fighting combat system with a general-purpose technology stack.
2. Layered Architecture
It is recommended to split the system into five layers that communicate only through well-defined interfaces:
- Presentation layer: character models, skeletal animation, stage, close-up cameras, particles, and post-processing.
- Input layer: keyboard/gamepad sampling, direction combination recognition, buffering, and priority.
- Logic layer: fixed-step state machine, frame data, hitboxes, energy and round rules.
- Physics layer: capsule/box collision, ground snapping, juggling, and knockback.
- AI layer: opponent decision-making, difficulty tiers, behavior trees or finite state machines.
The key principle is decoupling logic from rendering: logic advances at a fixed rate (for example, 60 frames per second), the render frame rate can fluctuate independently, and input is consumed uniformly at logic-frame boundaries.
Render frame (variable) -> Input sampling buffer -> Logic frame (fixed 60Hz) -> State machine/hit detection -> Presentation interpolation
3. Combat State Machine and Frame Data
Every character action should have a clear frame structure: startup frames, active frames, recovery frames, cancel windows, hitstun, and blockstun. Abstracting moves as data rather than hard-coded branches makes it easier for designers to tune them and for automated tests to verify them.
# Example: move frame data structuremove = {"name": "Dragon Punch","startup": 4, # startup frames"active": 3, # active hit frames"recovery": 12, # recovery frames"cancel_from": 6, # earliest cancel frame"hitstun": 18, # hitstun duration"blockstun": 8, # blockstun duration"knockback": 2.5, # knockback distance"launch": 6.0 # initial launch velocity}
State transitions must carry priority and interruption rules: a hit state cannot be interrupted by a normal attack; a block only takes effect if it is entered a few frames before being hit; throws have independent hit detection and ignore normal blocking. The core of a successful combo is the mathematical relationship between the “cancel window + target hitstun duration.” It is recommended to verify the feasibility of each combo with a frame table rather than relying on manual trial.
4. Input System and Directional Command Specials
Directional command inputs (such as “down-forward + punch”) require input buffering and a maximum interval constraint. In practice, a ring buffer is commonly used to record the directions and buttons from the most recent frames; matching allows unrelated inputs to be inserted and sets a timeout for invalidation.
Buffer example (one direction code per frame):[2,3,6,0,0,4] -> matches the 236 command (down, down-forward, forward)Rules: subsequence matching + maximum interval of 4 frames + same-frame button priority
A full-energy super move should act as a separate resource gate. When it is hit, the close-up camera is triggered, and the logic can briefly slow down or freeze input, but state consistency after recovery must be guaranteed to avoid the character getting stuck after the camera ends.
5. AI Opponent and Three Difficulty Tiers
Difficulty should not simply adjust numerical values; it should change decision quality and reaction windows:
- Easy: longer reaction delay, lower block probability, shorter combos.
- Standard: blocks and interrupts, occasionally uses special moves.
- Hard: predicts movement, applies proactive pressure, and manages resources more reasonably.
In implementation, a finite state machine can be combined with behavior scoring: weight distance, target state, and the AI’s own energy, then choose the action with the highest expected value, adding controllable randomness to avoid a mechanical feel.
6. Local Versus, Rounds, and Results
Local versus play needs to handle simultaneous same-frame inputs from two players and ensure the characters do not interfere with each other; a best-of-three format is managed by a round controller that handles timing, wins and losses, draws, and resets. Pause must freeze the logic clock and input buffer, and expired inputs should be cleared on resume to prevent pause exploits.
7. Performance and Debugging Checklist
- Use a fixed-step accumulator to avoid feel drift across different frame rates.
- Add a hitbox visualization toggle to verify hits and blocks frame by frame.
- Align animation events with hit frames to avoid “it looks like it hit but there is no detection.”
- Use interpolation for close-up cameras and camera shake to reduce motion sickness.
- Watch rendering batches and bone counts; on mobile, prioritize limiting the number of characters and post-processing layers.
8. Conclusion
The success of a 3D fighting project depends on how data-driven and verifiable the combat logic is. Making moves, hit detection, cancels, and hitstun adjustable data, guarding the feel with frame tables and automated test cases, and then gradually layering on AI opponents and camera presentation is the way to avoid the common trap of “great main menu, broken combat.”
