Tier Series 1

1B: Scope Authority

Pre-Flight
"In a commercial airliner, the passengers don't need access to the engine cutoff switch. Only the pilot does. If you give everyone access to every button, a simple mistake by a passenger could bring down the whole plane."
Sanity Check

The Concept: Public vs. Private

As we discuss in Chapter 1, variables have "Scope." This determines which other parts of your game can see or change that data.

public: Visible to every other script in the game. Use sparingly for "Shared" data.
private: Hidden from other scripts. This is the "Safe Default" for internal logic.
Concept Analysis
Audit Warning

The AI Trap: "The Open Cockpit"

You ask the AI: "Make a script that manages the player's internal movement speed."

// AI-Generated Code
public float moveSpeed = 5.0f; // Anyone can change this!

void Update() {
    // Movement logic...
}

Reasoning: If moveSpeed is public, a UI script or an Enemy script could accidentally change the player's speed. Your internal "engine data" should be protected.

Trap Breakdown

The Pilot's Correction

Operational Protocol Corrected
Solution Logic
// Corrected Pilot Code
[SerializeField] private float moveSpeed = 5.0f; 

// Now it is visible in the Unity Inspector, 
// but PROTECTED from other scripts.