AI Command Lab // Flight Simulator
300D: Directional Logic
Initial AI Output (Fragile)
// AI-Generated Code: Audit Failure (Messy & Heavy)
void Update() {
// Audit Fail: This requires complex angle math or
// a giant 'Cone' trigger that kills physics performance.
float angle = Vector3.Angle(transform.forward, player.position - transform.position);
if (angle < 45f) {
Attack();
}
}
Initial AI Prompt
"You ask the AI: "Check if the enemy is looking at the player before it attacks.""
Pilot Comm Link
Mission Objective: A skilled Navigator directs the AI to use the Dot Product.
Optimized Protocol
// Navigator Code: Fast & Mathematical
void Update() {
Vector3 toPlayer = (player.position - transform.position).normalized;
// Returns 1 if same direction, 0 if perpendicular, -1 if opposite
float dotProduct = Vector3.Dot(transform.forward, toPlayer);
// 0.7 roughly equals a 45-degree cone
if (dotProduct > 0.7f) {
Attack();
}
}