View Full Version : nParticles/ Instances - issue in expression
01-06-2011, 11:23 AM
By this expression, I want to kill particles based on their y position (if lower than my locator "killZone" set lifespanPP to 0).
vector $locPos = <<killZone.translateX, killZone.translateY, killZone.translateZ>>; vector $ptclPos = nParticleShape1.position;
if($ptclPos.y < $locPos.y)
nParticleShape1.lifespanPP = 0;
Although the condition is fulfilled (some WTF?'s in the script editor window tell me so), the particles seem not to be killed at all (at least, the instanced geometry is still existing although being lower than the locator's position)
The expression above has done a fine job for me in several std particles jobs- so why isn't it working in this case? Am I missing something?
Thank you for any answers!
01-06-2011, 03:26 PM
Not sure how that has ever worked. position is local space IIRC. And I believe in this way it will be the center of all particles combined, although you shouldn't quote me on that.
I extended your print statement to give more feedback, and once the first particle goes below the locator in world space, this is what the print statement says:
FIRST PARTICLE POS: .889105
LOCATOR Y POS: 0.911179414.
SHAPE.POS Y: -11.7591055
So lifespanPP doesn't seem to do anything here, and the nParticleShape1.position is giving a completely different position, as I guessed before, it must be local space, as -11 would be far below the locator, while this is not the case.
EDIT: My bad, forgot to set lifespan to lifespanPP only. So lifespanPP does work, but as the position variable isn't giving you a correct variable, it doesn't work as intended. I suggest you change the $ptclpos to something else, depending on the effect you want to create.
To get an accurate world space reading, I just took the position array of a single particle.
float $test = `getParticleAttr -at worldPosition nParticleShape1.pt`;
so then $test would be the translateY.
01-06-2011, 03:58 PM
dank u well!
I forgot to set lifespanPP only, too.
Even though the results of the position value might not be accurate, somehow this works pretty well.
01-06-2011, 09:45 PM
this is how i do it and it works every time
// creation and runtime
float $pos = worldPosition;
lifespanPP = 1000; (whatever number really)
if ($pos.y <= loc.ty)
lifespanPP = 0;
name of your locator is loc and it is positioned where you want it to kill the particles
01-06-2011, 09:46 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.