Please check out my game here: http://still-escarpment-3701.herokuapp.com
The problem is with shooting. The bullets keep on moving with the First person controller instead of moving from the same position and direction from which they were shot.
///////////////////code for shooting from fps///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// the bullet to be thrown and shoot ......
bulletTemplate = new J3D.Transform();
bulletTemplate.geometry = J3D.Primitive.Sphere(0.5, 4, 4);
bulletTemplate.renderer = J3D.BuiltinShaders.fetch("Normal2Color");
// bullet holder bullets ko apni gun main rakhe ga ....
bulletHolder = new J3D.Transform();
engine.scene.add(bulletHolder);
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
document.onmousemove = onMouseMove;
document.onmouseup = function(e) {
var b = bulletTemplate.clone();
var fz = first_person_controller.forward();
b.direction = new v3();
b.direction.fromArray(fz);
b.position.fromArray(fz).mult(3);
b.progress = 0;
b.ttl = 300;
b.animate = function() {
b.position = b.direction.cp().mult(3 + b.progress);
b.progress += 1;
b.ttl--;
if(b.ttl == 0) {
bulletHolder.remove(b);
}
}
bulletHolder.add(b);
};
The code below is being called in the game loop function's draw().
bulletHolder.position.x =first_person_controller.position.x;
bulletHolder.position.y =first_person_controller.position.y;
bulletHolder.position.z =first_person_controller.position.z;
first_person_controller.rotation.y = mx;
for(var i = 0; i < bulletHolder.numChildren; i++) {
bulletHolder.childAt(i).animate();
}
