Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 1: Moving Objects

Make a Boolean Variable

You don’t have access to this lesson
Please register or sign in to access the course content.

So far we have made a variable that is the number type, but there are actually many other types that we can use. Boolean is a long name for a simple type of variable that can only be either true or false

  1. Above the start function, create a new variable called shouldChestMove and set it equal to false.
  2. Save your script, and notice how Should Chest Move appears as a checkbox in the Entity panel, right under Amount To Move Up.
  3. When the box is checked, that is the same as setting the variable to true, and unchecked is the same as setting it to false.

Right now this won’t change any of the chest’s behavior. For that, we need an if statement.