Nicholas Yiallouris Posted August 22, 2014 Share Posted August 22, 2014 I have particles from one stream being grouped based on proximity and I'd like to deleted these particles after a certain time. So my question is: How would I reset the particle age when they enter the new group? Call it old habits but I like the option to reset the age every time a particle enters a new set of rules I'm trying to assign a popkill based on age / nage, and this is what I have so far: if (@nage > 0.1){ dead = 1;} else{ dead = 0;} This deletes the particles based their normalized age but it's not what I'm after, I'd like to delete them based on the time after they where grouped. Then my second question is how would I add a smooth transition or add a bit of randomness so they dont all disappear at once? Quote Link to comment Share on other sites More sharing options...
fathom Posted August 24, 2014 Share Posted August 24, 2014 i'd do it with a countdown kind of thing. if (ingroup("newGroup",ptnum)) // particle is in the new group { if (i@particleInitialized==0) // only re-init "new" particles { i@particleInitialized = 1; f@alive = hscript_rand(ptnum*3.45698) * X + Y; // X = variation of life time, Y = min life. result is particle lasts between X and X+Y seconds } f@alive = f@alive - TimeInc; if (f@alive <= 0) dead = 1; } Quote Link to comment Share on other sites More sharing options...
Nicholas Yiallouris Posted August 25, 2014 Author Share Posted August 25, 2014 (edited) Great thanks, but when I plug this VEX snippet into a popkill I get an error: Call to undefined function 'ingroup' I've change the group from "newGroup" to "Active" Am I missing something? Edited August 26, 2014 by Nicholas Yiallouris Quote Link to comment Share on other sites More sharing options...
nangu Posted August 26, 2014 Share Posted August 26, 2014 Great thanks, but when I plug this VEX snippet into a popkill I get an error: Call to undefined function 'ingroup' I've change the group from "newGroup" to "Active" Am I missing something? In a Vex expression inside these kind of nodes the ingroup() function doesn't work. You have to use the "group_GroupName" expression. In your example above, the line of code would be: if (group_Active == 1) { ..... } To put an element inside or outside a group, you assign "1" or "0" to the group expression, ie: group_Active = 1 // group_Active = 0 Quote Link to comment Share on other sites More sharing options...
Nicholas Yiallouris Posted August 28, 2014 Author Share Posted August 28, 2014 (edited) Still no luck. Now I'm getting another error which is saying "unexpected end of file" Maybe there's another approach to this, all I'm trying to do is have particles be deleted over 1 second as they enter a new group, perhaps someone has a simpler approach? Wrangle_PopKill.hip Edited August 28, 2014 by Nicholas Yiallouris Quote Link to comment Share on other sites More sharing options...
edward Posted August 28, 2014 Share Posted August 28, 2014 Your braces look mismatched to me. Aren't you missing a trailing } character? Quote Link to comment Share on other sites More sharing options...
fathom Posted August 28, 2014 Share Posted August 28, 2014 yeah, that last open brace is causing problems. Quote Link to comment Share on other sites More sharing options...
Nicholas Yiallouris Posted August 29, 2014 Author Share Posted August 29, 2014 (edited) Yes Indeed they where mismatched, thanks but the original problem persists: It looks like the VEXpression inside the popkill is not picking up the function "group_GroupName" or "ingroup()" . Is there another function I should be using? Wrangle_PopKill.hip Edited August 29, 2014 by Nicholas Yiallouris Quote Link to comment Share on other sites More sharing options...
anim Posted August 31, 2014 Share Posted August 31, 2014 here is the fixed file 2 popnets inside one using group as you have in your file second using stream, which is essentially the same thing, but visually cleaner as you can tell straight away which nodes are applied for which stream to do what you want you can just create popwrangle only for your group (or in desired stream) with this code: f@activeage += @Timeinc; then popkill (alsoo only on your group or in desired stream): dead = f@activeage>1; that's it activeage is completely custom name (you can create any nonexistent attribute for this purpose), it's just an attribute which will start counting only when particle is in the group/steam Wrangle_PopKill_fix.hip 1 Quote Link to comment Share on other sites More sharing options...
nangu Posted September 1, 2014 Share Posted September 1, 2014 Yes Indeed they where mismatched, thanks but the original problem persists: It looks like the VEXpression inside the popkill is not picking up the function "group_GroupName" or "ingroup()" . Is there another function I should be using? Sorry, my bad. The right expression is "@group_GroupName" (I missed the "@" in front) Quote Link to comment Share on other sites More sharing options...
Nicholas Yiallouris Posted September 8, 2014 Author Share Posted September 8, 2014 here is the fixed file 2 popnets inside one using group as you have in your file second using stream, which is essentially the same thing, but visually cleaner as you can tell straight away which nodes are applied for which stream to do what you want you can just create popwrangle only for your group (or in desired stream) with this code: f@activeage += @Timeinc; then popkill (alsoo only on your group or in desired stream): dead = f@activeage>1; that's it activeage is completely custom name (you can create any nonexistent attribute for this purpose), it's just an attribute which will start counting only when particle is in the group/steam Thank You Tomas ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.