Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 2: Making Code Respond to Players

Give the Function a Parameter

You don’t have access to this lesson

Please register or sign in to access the course content.

Right now, if you use this function, it will always move the chest lid to the opposite position. Sometimes that is useful, but other times you won’t want the chest lid to close just because you told it to open but it was already open. To do this, we’ll use a parameter.

  1. In the () parentheses after startLidAnimation, add a parameter called direction.
  2. Use : and String to specify the parameter’s type. In this case it’s a String, which is any collection of characters in “” quotes. We’ll be using “open” and “close”  to make sure the animation goes the right way.