ParticleSystems creation

Hi, quick question:
Does anyone succeed in particlesSystem dynamic instancing?

I’m not sure if it’s possible purely with the API, but you could manage it by putting a particle system into a block and instantiating the block dynamically.

Ok for example this code correctly instantiates particles, but they are invisible!

const Scene = require("Scene");
(async function () {
	const p = await Scene.create("ParticleSystem", { birthrate: 100 });
	const fd = await Scene.root.findFirst("Focal Distance");
	fd.addChild(p);
})();

I think you’d need to add a material, right?

Nope, does not work, but on click there is blue outline now.

image

const Scene = require("Scene");
const M = require("Materials");
(async function () {
	const p = await Scene.create("ParticleSystem", { birthrate: 100 });
	const fd = await Scene.root.findFirst("Focal Distance");
	fd.addChild(p);
	const mat = await M.create("DefaultMaterial");
	p.material = mat;
})();

Have you tried using the block instantiation method though? I feel like dynamically creating the particle system isn’t working because there’s some parameter not set (and there are a lot of them).

Here is all properties for default particle, the most important thing to note is colorModulationHSVA, it’s necessary but not in inspector:

4 Likes

Yes yes! You’ve cracked it!!!
Thank you

1 Like