The good news is that you’ve typed everything 100% correctly! The bad news… isn’t all that bad
The problem is that you’ve written the
animate() function 3 times. To fix, you just need to delete the first two.
animate() functions that need to be deleted start on line 53 and end on line 68. Delete all of that and you’ll have your avatar in the forest waving its hand!
The nitty gritty details (if you really want to know)…
What’s happened is that the first time the code calls the
animate() function on line 58, it goes all the way down to the last
animate() function body on line 105. That
animate() function calls
walk(), which tries to use the
clock variable is, since it’s defined right above
clock is still undefined because the code has only run through
animate() on line 58. The real fix is to wait to call
animate() until after
clock is assigned. By deleting the two
animate() functions – and the two calls – the code waits until the last
animate() to start
walk() and using the
clock. By then, the
clock is defined and everything works.