Tier 2
Series 103
103D: The Trigger State Machine
"Walking through a door is an event. Standing in a room is a state. If your fire trap only burns the player the exact millisecond they enter the room, but stops burning them while they stand in the flames, you've created Logic Gaps. A skilled Engineer audits for Enter vs. Stay."
The Concept: Enter, Stay, Exit
Triggers have three distinct phases. Confusing them breaks gameplay logic.
* **OnTriggerEnter:** Fires ONCE. Good for: Collecting a coin, playing a sound, triggering a cutscene.
* **OnTriggerStay:** Fires EVERY FRAME. Good for: Damage zones (Lava), healing zones, conveyor belts.
* **OnTriggerExit:** Fires ONCE. Good for: Closing a door, stopping a sound.
* **OnTriggerEnter:** Fires ONCE. Good for: Collecting a coin, playing a sound, triggering a cutscene.
* **OnTriggerStay:** Fires EVERY FRAME. Good for: Damage zones (Lava), healing zones, conveyor belts.
* **OnTriggerExit:** Fires ONCE. Good for: Closing a door, stopping a sound.
Red Flag Detected
The AI Trap: "The Sticky Trap"
You ask the AI: "Apply damage while the player is in the fire."
// AI-Generated Code: The "Safe" Fire
void OnTriggerEnter(Collider other) {
// Audit Fail: This runs exactly once.
// The player can stand in the fire forever without taking more damage.
ApplyDamage(10);
}
This is "One-Shot Logic." The AI confused the event of entering with the state of being inside. The trap becomes harmless after the first frame.
Elite Telemetry
Research shows "Elite" teams achieve 15% faster lead times by keeping AI on a "very tight leash."
- Small Batches Solving one problem at a time prevents logic drift.
- Modular Design Localizing the "blast radius" of AI changes.
- Tight Loops Rapid iteration with constant code review.
The Pilot's Correction
Corrective Protocol
// Corrected: Dangerous Fire
void OnTriggerStay(Collider other) {
// Runs every physics frame while inside
ApplyDamage(10);
}
Your Pilot Command
> Use Root Motion to ensure the character movement perfectly matches the animation.