PDA

View Full Version : controlling particle life with a locator


JasonA
12-27-2004, 02:12 PM
Hi folks,

I have a directional particle emitter aim constrained to a locator. I'd like to be able to have the particles life end when they reach the locator, but the locator's position can change during the animation, so the Particle Lifespan needs to change accordingly. Is there an easy way to make this happen?

Thanks!

brentorama
12-27-2004, 02:53 PM
How about this; assuming the locator is a goal object and that eventually all emitted particles will contact said locator - you could make a very simple collision object, like a four-sided prism and make it collide with your particles. Then create a particle collision event with all options unchecked except "original particle dies"

For a cleaner solution using scripting contact Nicool on this forum, he's got the answers to your particle woes.

JasonA
12-27-2004, 02:57 PM
Hey thats a cool idea! I might give that a try.

But I definitely would like to control it through a script. I've been flipping through some old vector notes, and I think I know how this could be done with a basic vector calculation using an expression for the lifespan attrbute.

Problem is, I have no idea how to build the syntax properly, but I do know what I need mathateically. Maybe Nicool (or anyone :)) will see my thread and help me out. I posted a thread with my idea in the MEL forum.

http://www.cgtalk.com/showthread.php?t=197499

Bonedaddy
12-27-2004, 04:22 PM
I think it'd be something like this, as a runtime attribute for your particle object. I don't have Maya right here, so my syntax may be off:




$partPos=particle1Shape.position;
$locPos=`getAttr locator1.position`;
$distance=5; //completely arbitrary length

$currentDistance=abs(mag($partPos-$locPos));

if ($currentDistance<=$distance) { particle1Shape.lifespanPP=0; }




The general idea is there. Find the two position vectors, subtract them and find the length of that vector. That'll be how far away it is, in absolute value. Then see if how it compares to some arbitrary distance you set up for it to die, and kill it if it gets too close.

If you want to be 133t with this, you could do a couple things:

1) Make the $distance attribute feed off of a custom "distance" attribute you give to your locator.
2) Make the runtime expression change the age of the particle instead of the lifespan, thus making it older as it gets nearer the locator. That way you can control neat stuff like radius, color, and opacity more easily.

Just some ideas.

CGTalk Moderation
01-20-2006, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.