AI Command Lab // Flight Simulator
200D: The Flight Computer
Initial AI Output (Fragile)
// AI-Generated Code: The "Zombie" Singleton
public static GameManager Instance;
void Awake() {
Instance = this;
DontDestroyOnLoad(gameObject);
// Audit Fail: If you reload the scene, a 2nd Manager creates itself.
// Now you have two scores updating at once!
}
Initial AI Prompt
"You ask the AI: "Create a GameManager to track the global score.""
Pilot Comm Link
Mission Objective: A skilled Architect directs the AI to Seal the Cockpit. You command: "Implement the Singleton pattern with a duplicate check to destroy imposters."
Optimized Protocol
// Corrected: The "Highlander" Rule (There can be only one)
void Awake() {
if (Instance == null) {
Instance = this;
DontDestroyOnLoad(gameObject);
} else {
Destroy(gameObject); // Self-destruct the duplicate
}
}