View Full Version : Proximity and Particle Behavior
11-13-2003, 04:49 AM
I want to have particles be effected by an object depending on their proximity to that object.
For example I create a locator and have particles dropping through space. When those particles come within a certain distance of the locator's position they get kicked back up into space then continue with their normal motion. I also want the degree to which the particles are affected depend on the distance from the locator, ie the locator has a falloff value. It's almost like a "pocket" of turbulence that effects only the particles that come near it.
So how do I define that area around the locator or define the distance relationship between the particles and the locator? What commands could I use?
11-13-2003, 05:04 AM
either a volume shape or use max distance(and attenuation) will do that, not sure how to implement it in mel though.
11-13-2003, 04:35 PM
I can't use any fields, though I guess what I am trying to do is create a custom field. Perhaps there is a way to simulate the max distance and attenuation attributes on a null object. Anyone have any ideas?
11-13-2003, 06:09 PM
Using the above senario I tried this script as a runtime expression, it is kinda like Level of Detail script, but modified:
]float $particleVec = `getAttr particleShape.position`;
string $locatorV = `spaceLocator -p`;
float $locatorX = `getAttr ($locatorV + ".tx")`;
float $locatorY = `getAttr ($locatorV + ".ty")`;
float $locatorZ = `getAttr ($locatorV + ".tz")`;
vector $locatorVec = <<$locatorX, $locatorY, $locatorZ>>;
//subtract the particle position and the locator vectors and take the
//magnitude of the resulting vector.
float $dist = mag($particleVec - $locatorVec);
int $threshold = 5;
//If the particle is less than 5 units from the locator change its direction
//If the particle is greater than 5 units from the locator assume normal direction
if ($dist< $threshold)
particleShape1.position = rot(position, <<0,0,1>>, -.01);
if ($dist > $threshold)
particleShape1.position = rot(position, <<0,1,0>>, -.001);
I get an error though when it hits this line:
]float $dist = mag($particleVec - $locatorVec);
// Error: float $dist = mag($particleVec - $locatorVec); //
// Error: Illegal operation "-" on data of type float. //]
Also creation of the locator takes place outside of the expression but I included it to make sense where the variable came from . Later I will randomize the location of the locator in space.
01-16-2006, 05:00 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.