AI Command Lab // Flight Simulator
101C: The Modular Asset
Initial AI Output (Fragile)
// AI-Generated Code: Heavy and Repetitive
public class Sword : MonoBehaviour {
public float damage = 10f;
public string description = "A sharp blade.";
// Audit Fail: If you have 100 swords,
// this data is copied into memory 100 times.
}
Initial AI Prompt
"You ask the AI: "Create a sword script with damage and description.""
Pilot Comm Link
Mission Objective: Implement an Event-based approach for the Jump action to save CPU cycles.
Optimized Protocol
// Corrected: Lightweight Reference
[CreateAssetMenu] // Allows right-click creation
public class SwordData : ScriptableObject {
public float damage;
public string description;
}
public class Sword : MonoBehaviour {
public SwordData data; // Points to the shared asset
}