Hey Chris,
I was working on the turn function in chapter 8 and I added the function.
Then, I put ‘turn();’ in the requestAnimationFrame(animate) line and it went gray.
Code:
function animate() {
requestAnimationFrame(animate);
walk();
turn();
acrobatics();
renderer.render(scene, camera);
}
animate();
Turn Function:
function turn() {
if (isMovingRight) direction = Math.PI/2;
if (isMovingLeft) direction = -Math.PI/2;
if (isMovingForward) direction = Math.PI;
if (isMovingBack) direction = 0;
if (!isWalking()) direction = 0;
avatar.rotation.y = direction;
}
Thanks,
Jakin