Right now, the chest animation will happen every single time you walk into the trigger. You can go ahead and test this, interrupting the animation and making it restart every time you. To fix it, we’ll create another variable that we set to true the first time the animation is finished, and only start the animation if it is false.
- In the ChestLidScript, create a variable above the start function named hasBeenDug and set it to false.
- In the moveChest function, find the else that happens once after the animation finishes, and set the hasBeenDug variable to true
- In the first line of the startDiggingUpChest animation, use an if-statement to check if hasBeenDug is true, and if so, use return to cancel the rest of the function.