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.
- Select the DigSpot, and from the Entity panel, create a new script.
- Name the script DigSpotScript and save.
- Create a new function called onTriggerEnter, and use console.log to write a message to the console that something entered the trigger.
- Repeat this for onTriggerStay, with a message that something is staying inside the trigger.
- And then do this again for onTriggerExit with a message