https://playcanvas.com/editor/scene/1636550
So. My game broke. (sort of). Ever since i made my gun script and enemy script, anytime the bullet collided with another entity or enemy, i would get an error. I would ignore this as i thought it was some bug that would be fixed sooner or later. But now, i have tried to add an enemy spawner that periodically spawns enemies. But every time the enemies are meant to spawn, 2 things happen: I get a ton of errors not of my doing and 2. The fps drops significantly. Here is the enemy spawner script.
var EnemySpawner = pc.createScript('enemySpawner');
EnemySpawner.attributes.add('enemy1', {
type: 'entity',
});
EnemySpawner.attributes.add('enemy2', {
type: 'entity',
});
// initialize code called once per entity
EnemySpawner.prototype.initialize = function() {
//set initial time
this.time = 0;
this.spawnNext = 1;
this.spawned = 0;
};
// update code called every frame
EnemySpawner.prototype.update = function(dt) {
// update time
this.time += dt;
if (this.time >= this.spawnNext) {
this.spawnNext = this.time + 1;
this.spawned += 1;
if (this.spawned <= 25) {
console.log("spawn1");
this.spawnEnemy1();
} else {
console.log("spawn2");
this.spawnEnemy2();
}
}
};
EnemySpawner.prototype.spawnEnemy1 = function(dt){
enemy = this.enemy1.clone;
this.app.root.addChild(enemy);
enemy.enabled = true;
};
EnemySpawner.prototype.spawnEnemy2 = function(dt){
enemy = this.enemy2.clone;
this.app.root.addChild(enemy);
enemy.enabled = true;
};
https://playcanvas.com/project/1027777/overview/idk-at-this-point
BTW i am working in branch “AM.” The main branch is completely useless.