2-09-2015 - UPDATE: The code provided below is now functional with the use of setLinearVelocity()
. If you were facing similar issues, this updated code may help you. Find the original question with the corrected code below...
A player object has been developed containing a Physijs.BoxMesh
. Currently, the perspective is third person for troubleshooting visibility, and the player can rotate the camera view and move in various directions. While rotation works seamlessly, I am encountering difficulties with mesh movement using setLinearVelocity()
.
Upon inspecting the velocity update through console.log(...getLinearVelocity), it seems to be updating correctly. Where might I be going wrong?
Player.js
function Player() {
// Body Mesh creation
this.bodyMesh = new Physijs.BoxMesh(
new THREE.BoxGeometry(25, 25, 25),
new Physijs.createMaterial(new THREE.MeshLambertMaterial({ color: 0xff0000 }), 1, .1),
1
);
this.camera;
// Default properties
this.fly = false;
this.cameraHeight = 40;
this.maxHealth = 100;
// Other properties omitted for brevity...
}
// Various functions defined for Player.prototype
Player.SPEED = 5;
Player.RADIUS = 20;
// Main game loop, animation setup, and other configurations follow...
Main.js
Physijs.scripts.worker = 'js/lib/physijs_worker.js';
Physijs.scripts.ammo = 'ammo.js';
// GLOBALS, SETUP, ANIMATION LOOPS, INPUT HANDLING are further extended...