AI Command Lab // Flight Simulator
100B: Collision Physics
Initial AI Output (Fragile)
// AI-Generated Code: Audit Failure
void OnCollisionEnter(Collision other) {
if (other.gameObject.CompareTag("Player")) {
// ERROR: The player will physically bump into the coin
// before this code runs, stopping their movement!
Destroy(gameObject);
}
}
Initial AI Prompt
"You ask the AI: "Write a script so that when the player touches a gold coin, the coin is destroyed and the player gets 10 gold.""
Pilot Comm Link
Mission Objective: A skilled Pilot uses a LayerMask to ensure the Raycast only interacts with specific objects.
Optimized Protocol
// Corrected Pilot Code: Smooth Flight
void OnTriggerEnter(Collider other) {
if (other.CompareTag("Player")) {
// The player glides through, triggering the event
// without losing momentum.
Destroy(gameObject);
}
}