Facing the Proper Direction
Getting the avatar to face the proper direction is fairly easyâespecially with all that we already know. Just as we did when we added the walking motion of the hands and feet, weâll add another function to animate turning our avatar.
Letâs start by going to the list of things that control our avatar.
â | âvarâ clock = ânewâ THREE.Clock(); |
â | âvarâ isCartwheeling = âfalseâ; |
â | âvarâ isFlipping = âfalseâ; |
â | âvarâ isMovingRight = âfalseâ; |
â | âvarâ isMovingLeft = âfalseâ; |
â | âvarâ isMovingForward = âfalseâ; |
â | âvarâ isMovingBack = âfalseâ; |
At the bottom of that list, add direction and lastDirection.
â | âvarâ direction; |
â | âvarâ lastDirection; ... |
Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.