Spawning Objects makes Armory3D game Lag

So I was making a game (like a crude version of minecraft). It requires spawning cubes by tapping different keys. However, after adding 6 cubes the game becomes very laggy and is unplayable after adding just 8 or 9 cubes.

I can’t figure out why this is happening, considering that there is almost nothing else in the game except for adding these cubes.

I’ve uploaded a screenshot that shows the node tree for adding cubes (the different cubes being spawned are just different colours) and the shader editor shows the shading of the cubes (they are simple diffuse shaders, so it should not be having a tough time rendering the shading)

Any insights would be really helpful. Thanks

Hi, is the node trait part of the spawned cube? If yes, you get exponential growth as every spawend cube will again spawn a cube and so on… If you look into the debug console you will probably see an ever-growing list of cubes in this case.

To solve this you should move the spawning trait to a different object than the spawned object itself.

3 Likes

Yes, I changed the trait to a different object and now it’s working flawlessly.
Thank you so much for the immediate fix.
Really appreciate it :smile:

2 Likes

I’ve made the same mistake myself… Maybe integrate it in the common mistakes page?

2 Likes

That’s a great idea! Done: https://github.com/armory3d/armory/wiki/Common-Mistakes#dont-put-a-trait-that-spawns-an-object-on-the-spawned-objects :slight_smile:

3 Likes