Tier 4
Series 305
305F: The Fleet Spawner
"In Multiplayer, `Instantiate` is dangerous. If you spawn a missile on your screen, it doesn't exist on the Server. It's a ghost missile. A Navigator uses the NetworkObject system to register new entities with the entire fleet."
The Concept: Network Spawn
To create an object that everyone sees, the Server must spawn it.
* **Instantiate:** Creates the GameObject in memory (Server only).
* **Spawn:** Assigns a NetworkID and tells all clients to "Clone this now."
* **Despawn:** Removes it properly from all machines.
* **Instantiate:** Creates the GameObject in memory (Server only).
* **Spawn:** Assigns a NetworkID and tells all clients to "Clone this now."
* **Despawn:** Removes it properly from all machines.
Red Flag Detected
The AI Trap: "The Local Spawn"
You ask the AI: "Spawn a fireball."
// AI-Generated Code: Desync
void CastSpell() {
// Audit Fail: This creates a local object.
// Other players will not see it, but they might take damage?
Instantiate(fireballPrefab, pos, rot);
}
This is "Ghost Object." The shooter sees the fireball, but the target sees nothing hitting them.
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 Navigator's Correction
Corrective Protocol
// Corrected: Fleet Registration
[ServerRpc]
void SpawnFireballServerRpc() {
GameObject go = Instantiate(prefab, pos, rot);
go.GetComponent<NetworkObject>().Spawn();
}
Your Pilot Command
> A skilled Navigator directs the AI to use Network Spawn.