FORUMS: list search recent posts

Slow down a random expression?

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Stanley Tang
Slow down a random expression?
on Apr 8, 2005 at 12:01:06 am

Hi all, can anyone tell me how to "slow down" a random command in an expression?

Let say I have a simple expression, XXX.tx=rand(-1,1). Now I only need the translationX to move every 5 frames instead of every single frame. How could I do that?


Return to posts index

Steve Sayer
Re: Slow down a random expression?
on Apr 8, 2005 at 3:25:15 pm

You can do this using an 'if' statement and the modulus operator:
if (frame % 5 == 0)
XXX.tx = rand(-1,1);
The modulus operator calculates the remainder of the division of the frame number by five. Only when the frame count is a multiple of five will this remainder be equal to zero. When that happens, the conditional statement executes, and the object is assigned a new position.

-Steve


Return to posts index

Stanley Tang
Re: Slow down a random expression?
on Apr 18, 2005 at 6:51:44 pm

Thanks Steven, I was looking for the modulus operation but couldn't find it. Thanks again!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]