Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 1: Moving Objects

Create Timing Variables

You don’t have access to this lesson

Please register or sign in to access the course content.

We need to specify how long the animation should take, and measure how long it has taken so far.

  1. Create two new number variables, animationTime and elapsedTime. Set animationTime to something long for now, like 3, and let elapsedTime start at 0.
  2. We can figure out how much time has passed using a handy property of the game called frameDeltaTime. It measures, in seconds, how long each tick takes.
  3. Just after the line where you increment the chest’s Y position, increment this.elapsedTime by
this.elapsedTime +=
  1. Add another line to log the value of elapsedTime to the console, so that we can see how long the animation currently takes.