Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script to control particles

1 REPLY 1
Reply
Message 1 of 2
jefersonfagundes2006
403 Views, 1 Reply

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

Script to control particles

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.

Labels (1)
1 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

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report