Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 3: Finishing the Game Loop

Move the Chest Before it Animates

You don’t have access to this lesson

Please register or sign in to access the course content.

Now we can figure out how to move the chest to the right place before it starts animating, to make it actually look like it is coming out of the ground at the dig spot.

  1. Give your startDiggingUpChestAnimation a parameter called digSpotPosition, with a type of Vector3. This will be the world position of the Dig Spot.
  2. Create a new variable with let called x, and set it to the x property of digSpotPosition.
  3. Create another variable with let called y, and set it to the y property of the digSpotPosition, but subtract amountToMoveUp from it so that it starts out under the Dig Spot, before it moves up.
  4. Create a z variable and set it to the z value of digSpotPosition.
  5. Set this entity’s world position to the x, y, and z  variables that you just made.