Skip to content

Instantly share code, notes, and snippets.

@BlueMagnificent
Created December 28, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueMagnificent/f79fafe468425a94a5f021cefba8034a to your computer and use it in GitHub Desktop.
Save BlueMagnificent/f79fafe468425a94a5f021cefba8034a to your computer and use it in GitHub Desktop.
Javascript 3D Physics Tut 2 Move Ball
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