WELL first of all I want you to see my game (its deployed on heroku cloud) :
http://still-escarpment-3701.herokuapp.com
(It takes almost 10 sec to load so please wait for couple of sec)
I have successfully implemented fps shooting .but same logic are not working for enemy to fps shooting ..:(
THE PROBLEM IS THAT :
Bullets gets saturated just after the shooting function is called ..i need enemy to shoot the bullets after some suitable delay just like its happening with fps shooting ...
bulletTempEnemy = new J3D.Transform();
bulletTempEnemy.geometry = J3D.Primitive.Sphere(0.5, 4, 4);
bulletTempEnemy.renderer = J3D.BuiltinShaders.fetch("Normal2Color");
bulletHolderEnemy = new J3D.Transform();
engine.scene.add(bulletHolderEnemy);
function EnemyShooting(){
bulletHolderEnemy.position.x =swat2.position.x;
bulletHolderEnemy.position.y =swat2.position.y;
bulletHolderEnemy.position.z =swat2.position.z;
var b = bulletTempEnemy.clone();
var f =v3.sub(first_person_controller.position,swat2.position).norm();
b.direction = new v3();
b.direction=f;
b.position.fromArray(f);
b.progress = 0;
b.ttl = 50;
b.animate = function() {
b.position = b.direction.cp().mult(1 + b.progress);
b.progress += 1;
b.ttl--;
if(b.ttl == 0) {
bulletHolderEnemy.remove(b);
}
}
bulletHolderEnemy.add(b);
}
and then code below was called in the game loop function draw()
var zdis= Math.abs(Math.abs(Math.abs(swat2.position.z) - Math.abs(first_person_controller.position.z)));
var xdis= Math.abs(Math.abs(Math.abs(swat2.position.x) - Math.abs(first_person_controller.position.x)));
if(xdis < 80)
{
setInterval(EnemyShooting(), 90000);
}
for(var i = 0; i < bulletHolderEnemy.numChildren; i++) {
bulletHolderEnemy.childAt(i).animate();
}
library used :J3D (https://github.com/drojdjou/J3D)
any help would be appreciated to resolve this saturation probLem of shooting bullets ....:|
