Tier 2
Series 105
105B: The Spawner
"You cannot hand-place bullets in the editor; they must appear when the gun fires. An Engineer uses `Instantiate()` to clone a Prefab into the world at runtime."
The Concept: Instantiation
The code command to clone a prefab.
* **Original:** The Prefab to copy.
* **Position:** Vector3 coordinates.
* **Rotation:** Quaternion orientation.
* **Return:** The new GameObject created.
* **Original:** The Prefab to copy.
* **Position:** Vector3 coordinates.
* **Rotation:** Quaternion orientation.
* **Return:** The new GameObject created.
Red Flag Detected
The AI Trap: "The Teleporting Bullet"
You ask the AI: "Fire the bullet."
// AI-Generated Code: Reuse Error
public GameObject bullet;
void Fire() {
// Audit Fail: This moves the ORIGINAL bullet blueprint.
// It doesn't create a new one.
bullet.transform.position = gunTip.position;
}
This is "Asset Modification." You are moving the "Blueprint" itself, or a single existing bullet, instead of creating a new one.
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 Engineer's Correction
Corrective Protocol
// Corrected: Cloning Instantiate(bulletPrefab, gunTip.position, gunTip.rotation);
Your Pilot Command
> Tell the AI to use NavMeshObstacles to allow agents to path around dynamic objects.