I cannot find MeshParticleEmitter in the API doc, is there a trick ?
It’s mostly the same thing as the ellipsoid particle emitter, so you use the same interface (i.e., ParticleEmitter).
–Eric
and to attach the mesh I use ParticleEmitter.mesh = mesh ? It’s not working so far.
gpe = g.AddComponent ( ParticleEmitter );
gPR = g.AddComponent ( ParticleRenderer );
gPR.material = particleMaterial;
gPR.maxParticleSize = 2.0;
gpe.mesh = g.GetComponent(Mesh);
gpe.Emit (100);
Nope, the emitter just uses the normal mesh component of the object, so you attach the mesh the usual way.
–Eric
When I play the following code it’s telling me:
“Can’t produce abstract class” on g.AddComponent ( ParticleEmitter )
“Can’t add component because the component ‘ParticleEmitter’ can’t be produced.”
var grassPatches : GameObject [];
var particleMaterial : Material;
function Start()
{
MossInit(1);
}
function MossInit(l : int)
{
for (var g in grassPatches)
{
var gpe : ParticleEmitter = g.AddComponent ( ParticleEmitter ); // a mesh emitter?
var gPR : ParticleRenderer = g.AddComponent ( ParticleRenderer );
gPR.material = particleMaterial;
gPR.maxParticleSize = 2.0;
gpe.Emit (100);
}
}
function MossMoss(l: int)
{
}
function Update ()
{
for (var g in grassPatches)
{
var gp : ParticleEmitter = g.GetComponent(ParticleEmitter);
gp.maxSize = Random.value*2.0;
}
}
As far as I know this is just something they forgot to do or got distracted halfway through implementing. I wouldn’t be surprised if it shows up in the next version.
Does AddComponent(“MeshParticleEmitter”) Work?
Also, as of 2.0 the mesh particle emitter has a mesh variable and doesn’t use the mesh filter anymore. Therefore it is impossible to asign a mesh to a mesh particle emitter at run time.
Oops…somehow I failed to notice that… I assume there was a good reason for that, but it kind of seems like not such a great idea at the moment.
–Eric