Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 3: Finishing the Game Loop

Create a Script for the Dig Spot and Add Trigger Functions

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

To test the way code works with a trigger, we can use three built-in functions that listen for trigger events, onTriggerEnter, onTriggerStay, and onTriggerExit.

  1. Select the DigSpot, and from the Entity panel, create a new script.
  2. Name the script DigSpotScript and save.
  3. Create a new function called onTriggerEnter, and use console.log to write a message to the console that something entered the trigger.
  4. Repeat this for onTriggerStay, with a message that something is staying inside the trigger.
  5. And then do this again for onTriggerExit with a message