Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 2: Making Code Respond to Players

Create a Function to Close the Chest Lid

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

Next, we need to create a new closeChest function. Create this under openChest.

Tip: Folding Code

When scripts get longer, it can get annoying to scroll through lots of code you aren’t working on right now. The dot big bang code editor allows you to fold code, which hides the lines inside a function or if-statement (basically anything with { }) when you don’t need to be looking at it.

  1. In the left margin of your code editor (near the line numbers), hover your mouse to see the character.
  2. Choose a function you aren’t using right now, like start, tick, and startOpeningLidAnimation and click the down arrow to fold the code.
  3. You can click the to the right of the function or the > in the left margin to open the code again when you need to work on it.