Skip to Content

Sample Emit on Collision Procedure

Create this in the expression editor (filtering by script Node).  It's what I used for my avalanche.

 

 

global proc mySnowProc(string $particleName, int $particleID, string $objectName)
{

//float $pos[] = `getParticleAttr -at position $particleName.pt[$particleID]`;
float $pos[] = `particle -at position -id $particleID $particleName -q`;

//float $vel[] = `getParticleAttr -at velocity $particleName.pt[$particleID]`;
float $vel[] = `particle -at velocity -id $particleID $particleName -q`;

//print($pos[0] + " " + $pos[1] + " " + $pos[2] + " " + $pos[3] + " " + $particleID);

int $i;
int $MaxNumParts = 4;
float $velScale;
float $posScale;
string $emitCmd = "emit -object snowDust ";
for ($i=0; $i<=$MaxNumParts; $i++)
{
$velScale = 1;
$posScale = rand(-.3, .3);
$emitCmd += "-pos " + ($pos[0]+abs(3*$posScale)) + " " +($pos[1]+$posScale) + " " + ($pos[2]+$posScale) + " ";
vector $v = $velScale * << 2*$vel[0]+$posScale, $vel[1]+$posScale, $vel[2]+$posScale>>;
$emitCmd += "-at velocity ";
$emitCmd += "-vv " + $v + " ";
}
eval($emitCmd);

//print $emitCmd;

}

}

Which ones do I need to

Which ones do I need to change, to match my particles' name? Is it just the "particle Name" part that needs to be adjusted?

 

And, where do I create this? I tried to create it in the expression editor, by making new script node, but which option do I select for the "Execute On"? Also, is it "Before" or "After"? 

Be sure to read the book.

Be sure to read the book. There is an example that uses this type of emission procedure.  Look in the emit function chapter.

 

You need to change "snowDust" to the name of the particle bucket that you are using.