PDA

View Full Version : Slow down an expression


KungKrille
06-22-2009, 02:32 PM
I have a particle field with this script to animate the position in a random way:

float $x = rand(-0.25, 0.25);
float $y = rand(-1, 1);
float $z = rand(-0.5, 0.5);

particleShape1.position += <<$x, $y, $z>>;

This runs too fast though so I wonder how I can slow down the movements.

benio33
06-22-2009, 02:37 PM
$frameInterval=2;

if (frame%$frameInterval==0)
{
float $x = rand(-0.25, 0.25);
float $y = rand(-1, 1);
float $z = rand(-0.5, 0.5);

particleShape1.position += <<$x, $y, $z>>;
}

This will lunch the expression every 2'nd frame, if you want slow it down more, just increase the interval by integers.

KungKrille
06-22-2009, 02:52 PM
Thanks, that was almost what I wanted. The problem is that the changes in position are not interpolated so the particles moves in a jerky way at large intervals.

It´s understandable as they get a new random position at every iteration. Maybe I´m approaching this in the wrong way. I want the particles to move randomly at their initial position but slow and smooth.

benio33
06-22-2009, 03:07 PM
Then you should use noise not random.

Create an per particle float attribute - RandomSeed. On creation expression put RandomSeed = rand(-1,1), then in runtime expression after dynamics put:

float $x = noise(time+(RandomSeed));
float $y = noise(time+(RandomSeed*1.1))
float $z = noise(time+(RandomSeed*1.2))

particleShape1.position += <<$x, $y, $z>>;

KungKrille
06-23-2009, 07:32 AM
Thank you :) Noise! I shall remember that one. Exactly what I needed :)

CGTalk Moderation
06-23-2009, 07:32 AM
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.