The most complex programming problems can often be boiled down to sets of simple choices that a game or program evaluates and acts on. Since Visual Studio and Unity can't make those choices by themselves, writing out those decisions is up to us.
The if-else and switch selection statements allow you to specify branching paths, based on one or more conditions, and the actions you want to be taken in each case. Traditionally, these conditions include the following:
- Detecting user input
- Evaluating expressions and Boolean logic
- Comparing variables or literal values
You're going to start with the simplest of these conditional statements, if-else, in the following section.