Time for action – create if statements with more than one condition to check

  1. Modify LearningScript as shown in the next screenshot.
  2. Save the file.
  3. In Unity, click on Play.
    Time for action – create if statements with more than one condition to check

Note

Notice line 11 is using the AND operator, and line 16 is using the OR operator.

What just happened?

Here is the output you get in the Unity Console:

What just happened?

Code analysis:

  • The code on line 8 and its description:
    bool theBearMadeBigPottyInTheWoods = true;

    A bool variable is declared and assigned the value of true.

  • The code on line 9 with its description:
    int temperature = 40;

    An int variable is ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.