Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 2: Making Code Respond to Players

Check that the Chest Lid Exists First

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

To handle the possibility that chestLid could be null, we’ll use an if-statement to only run the next line if it does, in fact, exist. To do this, we need the NOT-EQUALS operator, !=

  1. Before the chestLid sendEvent line, add an if statement.
  2. Move the final } curly bracket to be after the chestLid sendEvent line.
  3. Make the condition of the if-statement that the chestLid does not equal null
  4. Indent the chestLid sendEvent line.