Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 3: Finishing the Game Loop

Make a Function to Set the hasTreasure Property

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

To make TreasureControllerScript able to make one of the dig spots have treasure, we need a function for it to call that changes the value of the hasTreasure variable. 

  1. Below your onTriggerEnter function, create a new function called setHasTreasure.
  2. Give that function a parameter called treasure of type boolean.
  3. In the function, set the hasTreasure variable to whatever the treasure parameter is (either true or false).