CiaranM
03-22-2007, 03:56 PM
Hi there,
I've written this little expression to generate a 'travelling wave' along a row of objects (looks even cooler when applied to a large matrix of objects!)
int $x, $i, $numBalls;
float $ballPosition, $freq, $amp, $wavelength, $yShift;
select -ado "ball*";
select -d -adn;
string $objects[] = `ls -sl`;
$numBalls = size($objects);
select -d;
for ($i = 0; $i < $numBalls; $i++)
{
$yShift = 1;
$amp = 5;
$freq = 3;
$wavelength = ((time - $i)*$freq);
$ballPosition = ($amp * (cos($wavelength)) + $yShift);
setAttr ($objects[$i]+".ty") $ballPosition;
}
However I'm not happy that I am controlling each object's Y translation using a setAttr command. I expect that this slows down the execution of the expression and is not recommended. How can I do this without setAttr? I can't seem to get the syntax right. Or is it not possible?
Any help is appreciated!
I've written this little expression to generate a 'travelling wave' along a row of objects (looks even cooler when applied to a large matrix of objects!)
int $x, $i, $numBalls;
float $ballPosition, $freq, $amp, $wavelength, $yShift;
select -ado "ball*";
select -d -adn;
string $objects[] = `ls -sl`;
$numBalls = size($objects);
select -d;
for ($i = 0; $i < $numBalls; $i++)
{
$yShift = 1;
$amp = 5;
$freq = 3;
$wavelength = ((time - $i)*$freq);
$ballPosition = ($amp * (cos($wavelength)) + $yShift);
setAttr ($objects[$i]+".ty") $ballPosition;
}
However I'm not happy that I am controlling each object's Y translation using a setAttr command. I expect that this slows down the execution of the expression and is not recommended. How can I do this without setAttr? I can't seem to get the syntax right. Or is it not possible?
Any help is appreciated!
