Hi everyone, just wanna ask if its possible to spawn and delete entity by distance and not timer? been using this script for timer spawn and delete. thanks in advance
EntityCreator.prototype.update = function(dt) {
while (this.entities.length < this.maxCubes) {
this.spawnCube();
}
// Loop through Entities and delete them when their time is up
for (i = 0; i < this.entities.length; i++) {
this.entities[i].timer -= dt;
if (this.entities[i].timer < 0) {
// entity.destroy() deletes all components and removes Entity from the hierarchy
this.entities[i].entity.destroy();
// Remove from the local list
this.entities.splice(i, 1);
}
}
};