Did you miss me? I hope you can help me

So, i i am now at chapter 6 and i am at page 75 and i got errors at the js. Console.
Console’s output: code.html:124 Uncaught TypeError: Cannot read property ‘GetElapsedTime’ of undefined
at walk (VM182 code.html:124)
at animate (VM182 code.html:114)
and Url of the script is:
https://is.gd/PSjTkO
I very very very hope you can help me (again) :grinning: :smiling_face_with_three_hearts:

Yup. That was a tough one. Even people that have been doing JavaScript for years run into problems like this all the time.

To fix, delete the code on lines 92-97. That is, delete the following:

function animate() {
  requestAnimationFrame(animate);
  acrobatics();
  renderer.render(scene, camera);
}
animate();

The short explanation is that there are two different animate() functions (and calls) and the first one is not needed.

The long explanation is trouble starts on the last line, the call to the animate() function. It’s not calling the animate() function that starts on line 92. Instead, it’s calling the animate() function that is defined later in the code. When animate() is called on line 97, it is before the clock variable is defined. When the second animate() function tries to run, it ask the clock variable to return the elapsed time. But clock is not yet defined, so we get an error. And, since animate() is called several times a second, you get LOTS of those errors.

Sorry for the delay in getting back to you. I’m almost positive you would have found this on your own, but just so you don’t have to wait in case you can’t, there’s another bug in that code that was being “hidden” by the above problem. In the walk() function, the “G” in clock.getElapsedTime() should not be capitalized.

So, change this:

  var time = clock.GetElapsedTime();

To this:

  var time = clock.getElapsedTime();

After that, your code should be working perfectly.

-Chris