Does it need all of that? Looks like overkill for what is going on in the game
It does not, I am trying to think of a system where it only fires once per platform.
Do you have any ideas on how I could do this? I was thinking dynamic names or tags. Or a parameter on the event.
Had a quick profile and as Kulodo133 mentioned, it’s all physics bound.
You are creating WAY too many collision objects and the physics simulation is what is taking up CPU resources
When I paused the game, it had 2100+ collision objects

4/5 entities that could be cloned have a collision component. ![]()
this is the how.
is it possible to have a global variable that increases at the triggervolume, and then the obstacle saves that on initilizse, and the script saves it. So if the event is fired with an argument of the saved variable, it would check that that is the correct number, then run it?
something like this:
Script A
let generation = 0;
this.entity.collision.on('triggerenter', function (entity) {
generation +=1;
this.myGeneration = generation;
fire("populate",this.myGeneration);
};
Script B
//Initilize
this.myGenerationB = generation;
const funct = function(n){
if(this.myGenerationB === n){
//populate
};
};
this.app.on('populate', makeobject);
This is a very rough draft.
Im going to take a break for a bit and come back to this.
The main issue is that you always cloning the platform after it’s created some obstacles.
ie
Platform 1 creates 2 obstacles.
You collide with TriggerMake.
Platform 1 gets cloned as Platform 2 as is and then creates 2 more obstacles. You now have 4 obstacles as children of Platform 2.
You collide with TriggerMake.
Platform 2 gets cloned as Platform 3 as is and then creates 2 more obstacles. You now have 6 obstacles as children of Platform 3.
etc
I’m looking if there’s an easy solution here without having to do a massive rewrite
Hey, Ill do a massive re-write.
I don’t have time to fully explain this but basically, it’s a lot easier to handle the spawning of objects outside the object that is cloned/spawned
https://playcanvas.com/project/1289201/overview
I deleted the background object to focus on the platforms but the TLDR is that the TriggerMake now fires a global event that a script on the root object is listening for and it handles the spawning platforms
This allows the the original object to be ‘clean’ to clone.
The alternative is to use template assets for all the objects that you would spawn or use fixed size entity pools.
Thank you! I am going to go eat lunch, then fix my project. I cant thank you enough, you might have just saved my game jam.
It works now, thanks!
I know this is solved, but @yaustar , if I add a new entity to the pool attribute it should spawn it, right? I added a new entity and it is not working.
The blueUp and the polarity Swapper (new) arent spawning, well, I got the polarity swapper to spawn once, just not again. Here is the new editor link.PlayCanvas | HTML5 Game Engine
You have to be more specific here. Are you changing the right platform object in the editor?
The Platform Original that is disabled is the one to change
Thanks for pointing that out! I forgot that.
