Engineering a 3D Fighting Game: A Practical Implementation Path
This article outlines an engineering approach to building a 3D fighting game, focusing on why polished character showcases often fail to translate into playable combat. It explains a four-layer architecture built around a deterministic logic core, frame-based state machines for character moves, layered hitbox collision with priority resolution, quality-driven AI difficulty, input buffering for responsive controls, and rendering trade-offs for readability. It also covers replay-based regression testing, observability, and common pitfalls to avoid.
1. Problem Definition: Why Showcases Look Good but Combat Feels Broken
In many 3D fighting game prototypes, the main menu and character showcases are highly polished, yet the experience falls apart once actual combat begins. Handling, hit detection, and pacing quickly expose engineering gaps. The root cause is rarely the art. It is that the showcase and the combat layer operate under completely different technical constraints. The showcase prioritizes cinematic camera work and visual impact, with high fault tolerance and shallow interaction. The combat layer demands deterministic frame progression, reproducible input sampling, and strict collision detection. Any jitter in the time step turns into a tangible problem: attacks miss, blocks fail, and combos drop. For this reason, the combat layer should be built as a deterministic core first, with the showcase layered on top, not the other way around.
2. Overall Architecture: Four-Layer Separation and a Deterministic Core
Split the system into four layers: input, logic (the deterministic core), presentation, and resources. The logic layer advances at a fixed step. The input layer handles sampling and buffering. The presentation layer only performs interpolated rendering. The resource layer manages loading and releasing models, animations, and audio. The four layers communicate through read-only snapshots so that rendering frame rate fluctuations cannot pollute the logic in reverse.
Input sampling (60Hz) -> Command buffer -> Fixed-step logic (1/60s) -> State snapshot|-> Collision and hit resolution|-> AI decisionsvPresentation layer interpolated rendering
A schematic main loop:
FIXED_DT = 1.0 / 60.0acc = 0.0while running:acc += frame_timeinputs = sample_inputs() # Sample and write to ring bufferwhile acc >= FIXED_DT:snapshot = logic.step(inputs, FIXED_DT) # The only place the world advancesacc -= FIXED_DTrenderer.draw(interpolate(prev_snapshot, snapshot, acc / FIXED_DT))
The key point: the logic layer never accepts a variable frame length, and the rendering layer never modifies world state. This keeps behavior consistent across local two-player matches, pause and resume, and slow-motion close-ups.
3. Characters and Moves: Describing Interruptibility with State Machines
Two independent characters should not be two copies of the same code. They should be one move state machine with different parameter sets. Each state must declare whether it can be interrupted by an attack, whether it can be canceled, its displacement curve, and its active-frame window. Jumps, dashes, juggles, throws, and blocks are all modeled as state transitions. Combo canceling is a special case: transitioning to the next state within an allowed window.
Idle -> Walk -> Dash -> Jump -> Land| | | |+->Block +->Throw +->AirAtkAttack -> (CancelWindow) -> Attack2 / Special / Super
Parameterized example:
{"move": "dash","startup": 4,"active": 3,"recovery": 9,"cancel_from": ["attack", "special"],"invuln_frames": [0, 2]}
Once “feel” is broken down into quantifiable parameters, tuning has a basis instead of relying on repeated playtesting and luck.
4. Hit Detection and Collision: Layered Boxes and Hit Priority
3D fighting hit detection typically uses capsules or layered boxes: attack boxes, hurt boxes, and throw boxes are independent of one another. Each frame, first do a broad phase (bounding volumes), then a narrow phase (box intersection), and finally resolve by priority: throws outrank normal attacks, and super moves have higher priority plus brief invulnerability frames. Detection results must be written to an event queue and consumed uniformly by the logic layer, so the presentation layer cannot directly modify health bars and cause desynchronization.
def resolve(hit_events):hit_events.sort(key=lambda e: e.priority, reverse=True)for e in hit_events:if e.target.invuln: continuee.target.apply_hit(e.damage, e.hitstun)break # Only the highest priority is settled per frame
5. AI: Three Difficulty Tiers from Decision Quality, Not Stat Inflation
Easy, normal, and hard tiers should not differ only by damage multipliers. The difference should show up across perception, reaction, and strategy. Easy lowers reaction frequency and shortens combos. Normal adds blocking probability and distance management. Hard introduces opponent habit modeling and resource management (energy, throw breaks). Implementation can use a finite state machine plus a behavior tree, or a lightweight utility score:
def choose_action(self, obs):dist = obs.distanceif obs.incoming_attack and rng() < self.block_prob:return "block"if dist < 1.2 and self.energy >= 100:return "super"return self.behavior_tree.tick(obs)
Difficulty differences concentrate in parameters such as block_prob, combo table length, and decision interval, which makes balancing and regression testing easier.
6. Input and Feel: Buffering, Pre-input, and Local Two-Player
Fighting game feel depends heavily on input buffering and pre-input windows. Maintain a fixed-length ring buffer that records the most recent frames of directions and button presses, used for special move recognition and combo canceling. Directional special moves are implemented through sequence matching, which must tolerate one frame of jitter and set a timeout. Local two-player matches must sample both input streams within the same logic frame to avoid one side stealing frames due to delay. Pause and results screens are time scaling and state freezing in the logic layer, while the presentation layer keeps interpolating.
7. Stage and Camera: Rendering Trade-offs for a Rainy Rooftop
For a rainy night scene, readability takes priority over realism. Wet ground uses roughness maps plus reflection approximations, rain streaks use particles and screen-space distortion, and neon uses glow with lightweight post-processing. Characters must keep clear silhouettes, avoiding an overexposed background that swallows hit cues. Close-ups and super move cutscenes should be time scaling and camera interpolation in the presentation layer, without changing logic frame progression, otherwise determinism breaks.
8. Engineering Practices and Observability
Build replay and regression cases for the logic layer: a fixed input sequence produces a fixed state hash, so any change can be detected. Logging and monitoring can use general categories, such as a logging service, monitoring and alerting, and object storage for saving replay files. If cloud matches or resource distribution are needed, general container platform and object storage capabilities can be used, but core hit resolution should stay in the deterministic core. For performance, watch three metrics: logic frame time, collision pair count, and render batches. Do broad phase before narrow phase, and avoid full pairwise checks.
9. Common Pitfalls Checklist
- Driving logic with the rendering frame length, causing inconsistent feel across devices;
- Making difficulty pure stat inflation, which players perceive as cheating;
- Coupling detection with presentation, causing “it looks like it hit but no damage was dealt”;
- No input buffering, making specials and cancel windows useless;
- Stage effects overpowering character silhouettes, reducing combat readability.
Proceed in the order of deterministic core, layered presentation, parameterized characters, and quality-driven AI. Only then can the high-completion showcase from the prototype stage naturally carry over into a complete combat experience that is playable, tunable, and regression-testable.
