Chapter 5. Making Decisions in Code
One of the primary duties of a computer is controlling what happens next when certain conditions are met. That's what computers do whether the code is controlling an application or a game. We write scripts to make GameObjects behave a certain way one moment, then the behavior should change when the conditions change. A script has to detect when the conditions change, then make the appropriate code execute based on the new conditions. This chapter looks at some examples of the ways that conditions can change, and the code to detect these changes. This in turn determines which code in the script is executed next.
In this chapter we will discuss:
- If statement decisions
- Checking for many conditions
- If-else statement decisions
- User's input condition changes
- Looping though data in an Array, List, or Dictionary
Let's begin...