Hi,
i’m a newbie in three.js, phaser i know but it’s really different
I made a simple fps and when i shoot my enemy is destroy with particles effects.
The problem is that the particles spawn at the beginning position of my enemy who’s moving see the gif
my snippet for spawn the particles is :
enemys.forEach(box => {
if ((this.object.position).distanceTo(box.mesh.position) < 100) {
//scene.remove(this.object);
if (box.mesh.alive) {
var vec = new THREE.Vector3().copy(box.mesh.position);
particlesHolder.spawnParticles(vec, 10, Colors.enemy, random(.5, 1));
}
box.mesh.alive = false
scene.remove(box.mesh);
}
});
ParticlesHolder.prototype.spawnParticles = function (pos, density, color, scale) {
var nPArticles = density;
for (var i = 0; i < nPArticles; i++) {
var particle;
if (particlesPool.length) {
particle = particlesPool.pop();
} else {
particle = new Particle();
}
this.mesh.add(particle.mesh);
particle.mesh.visible = true;
var _this = this;
particle.mesh.position.y = pos.y;
particle.mesh.position.x = pos.x;
particle.mesh.position.z = pos.z;
particle.explode(pos, color, scale);
}
}
How do you get the real position of the enemys ?
Thanks a lot.