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.
- Modify
LearningScript
as shown in the next screenshot. - Save the file.
- In Unity, click on Play.
What just happened?
Here's the output in the Unity Console:
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.