Created
December 28, 2019 10:38
-
-
Save BlueMagnificent/f79fafe468425a94a5f021cefba8034a to your computer and use it in GitHub Desktop.
Javascript 3D Physics Tut 2 Move Ball
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveBall(){ | |
let scalingFactor = 20; | |
let moveX = moveDirection.right - moveDirection.left; | |
let moveZ = moveDirection.back - moveDirection.forward; | |
let moveY = 0; | |
if( moveX == 0 && moveY == 0 && moveZ == 0) return; | |
let resultantImpulse = new Ammo.btVector3( moveX, moveY, moveZ ) | |
resultantImpulse.op_mul(scalingFactor); | |
let physicsBody = ballObject.userData.physicsBody; | |
physicsBody.setLinearVelocity( resultantImpulse ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment