Time for action – create a couple of if statements

The if statements work by determining whether a condition inside a pair of parentheses is true or false.

  1. Modify LearningScript as shown in the next screenshot.
  2. Save the file.
  3. In Unity, click on Play.
Time for action – create a couple of if statements

What just happened?

Here's the output in the Unity Console:

What just happened?

Code analysis:

  • The code on line 8 is as follows:
    bool theBearMadeBigPottyInTheWoods = true;

    This Boolean variable is declared and assigned the value of true.

  • The code on line 10 and its description:
    if( theBearMadeBigPottyInTheWoods)

    An if statement to ...

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.