Script to control particles

Script to control particles

jefersonfagundes2006
Explorer Explorer
501 Views
1 Reply
Message 1 of 2

Script to control particles

jefersonfagundes2006
Explorer
Explorer

Hi there, this is my first post. I’m making a text animated using particles (wrote a word using nParticles and added a Volume Axis to move the particles), it’s working great, but I would like to know if I can destroy the particles separately based on its amount of movement.

For example, using MEL, get the start position of each particle and, when the distance is greater than “10” this particle is removed/destroyed. I have only two things in Outliner: particle1, volumeAxisField1 (the other things do not have any inffluence in my particle animation)

I know C++ and C#, but not MEL. Where can I found examples of MEL scripts? Is possible anyone show a generic code about what I wanna do? I would appreciate any help. My Maya version is 2020.

0 Likes
502 Views
1 Reply
Reply (1)
Message 2 of 2

jefersonfagundes2006
Explorer
Explorer

Ok I did.

In "particleShape1":

-> "Lifespan Attributes" -> Lifespan Mode: lifespanPP only

-> "Per Particle (Array) Attributes" -> Lifespan PP -> Right click and Create Expression...

--> In "Objects" select particleShape1

--> In "Attributes" select lifespanPP

--> Check "Runtime after dynamics"

--> In "Expression" use the code:

vector $pos = particleShape1.position;
float $dist = mag(<<$pos.x, $pos.y, $pos.z>>);
if ($dist > 32 ) lifespanPP = 0;

////////Now it's working