To do this we need a couple more variables and the conditional statement.
First, a vector variable to representthe size of the field's range. Enter this in the expression editor:
vector $distance0=<<$range0,$range0,$range0>>;
19. Then add a variable for the particle's velocity:
vector $velo=particleShape1.velocity;
20. And the conditional statement:
if (abs($pos-$goal0Pos)<$distance0)
$velo=0;
21. And finally we need to set the velocity of the particles to the $velo variable:
particleShape1.velocity=$velo;
Altogether the runtime expression should look like this:
vector $goal0Pos=particleShape1.goalWorldPosition0PP;
vector $pos=particleShape1.position;
float $range0=.5*freezeField0.fieldSize;
vector $distance0=<<$range0,$range0,$range0>>;
vector $velo=particleShape1.velocity;
if (abs($pos-$goal0Pos)<$distance0)
$velo=0;
particleShape1.velocity=$velo;
Test out the animation.
As the particles come within the edge of the range, represented by the sphere, they will stop moving.
Try animating the position of the freeze field and the size of the range. Once you do this you should say to your self "big deal, all that work for that?"
Ok, not exactly Episode III quality stuff here, but, once again, this tutorial is meant to get you familiar with the new per particle goal attributes in Maya 7. It becomes slightly more interesting when we add a second goal.
22. Select the particle shape and the freezeField1 object. Choose particle>goal.
23. Open up the attribute editor for the particle shape. Notice that a new set of buttons has been added to the goal weights and objects folder. Hit the buttons for create goalWeight1PP and create goalWorldPosition1PP.
24. Now we just have to edit the expressions to add the second freeze field.
Open up the expression editor and switch to creation expressions. Change it so that it reads:
particleShape1.goalWeight0PP=0; particleShape1.goalWeight1PP=0;
25. Switch to runtime before dynamics and edit the variables so that it reads:
vector $goal0Pos=particleShape1.goalWorldPosition0PP; vector $goal1Pos=particleShape1.goalWorldPosition1PP;
vector $pos=particleShape1.position;
float $range0=.5*freezeField0.fieldSize;
float $range1=.5*freezeField1.fieldSize;
vector $distance0=<<$range0,$range0,$range0>>;
vector $distance1=<<$range1,$range1,$range1>>;
vector $velo=particleShape1.velocity;
26. Now we'll change the conditional expression so that it says "if the absolute value of the difference between the particle's position and the freezeField0's world position is less that the size of the freezeField0's range OR the difference between the particle's position and the freezeField1's world position is less that the size of the freezeField1's range, set the velocity of the particle to zero." The syntax for OR in the expression editor is "||".
Author: robotball
Submitted: 2005-10-09 23:31:21 UTC
Tags:
Software: Maya
Views: 55,012
Related Items
-
Realistic sexy posed brunette woman in multiple outfits vinyl and lingerie 3D Model
$69.00 (USD) -
Elephant 3d textured model 3ds max and maya scene files 3D Model
$30.00 (USD) -
Tire and Rim 3D Model
$9.00 (USD) -
Kangaroo Rigged and Animated 3D Model
$30.00 (USD) -
j-7 3D Model
$120.00 (USD) -
Blonde woman in jeans and sweater - aXYZ design - AWom0004-CS / Rigged for 3D Max + Character Studio 3D Model
$49.00 (USD) -
7.62x25 Tokarev Cartridge 3D Model
$25.00 (USD) -
7.62x51 NATO Cartridge 3D Model
$25.00 (USD) -
7.62x39 Cartridge 3D Model
$25.00 (USD)