Control Flow & Loops

Control flow is how a script decides what to do and how many times to do it: if, else, and switch make decisions, for, foreach, and while repeat work. Almost every gameplay rule, from "is the player in range" to "spawn ten enemies in a row", is one of these shapes, and reading them without effort is the first real programming skill.

More in C# Foundations

  1. Variables & Types
  2. Control Flow & Loops
  3. Methods & Classes
  4. Collections
  5. Interfaces & Inheritance
  6. Delegates & Events

All 42 topics in the Learn Unity Roadmap