FORUMS: list search recent posts

Expression

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Emmanuel Mazeron
Expression
on Apr 8, 2008 at 7:13:25 pm

Hi,

I'm creating a domino effect. I need to write an expression
to control the Z rotation of domino #2. This rotation (domino#2)
is equal to the first domino rotation -1 frame.

How can I isolatem bZ rotation value at previous frame of domino #1?

Thank you very much.

Maz



Return to posts index

Steve Sayer
Re: Expression
on Apr 16, 2008 at 2:54:38 am

It is possible to have an expression get the value of an object's attribute at a time other than the present time, but it is not recommended, as the process is very inefficient.

It will be much better if you can control the rotation of all your dominoes, even the first one, using the same expression (I'm assuming you want to control X dominoes, where the rotation of domino X at any frame is the same as the rotation of domino (X-1) at the previous frame).

I think a command that will be useful to you is the eval command. This allows you to construct a command out of strings and variables, meaning you can iterate through a loop and execute a command (such as rotate) on a whole collection of objects with similar names (such as 'domino1' 'domino2' 'domino3' and so on).

The command works something like this:

eval ("command string" + "another string" + $variable + ... );

You can add together as many strings and variables as you like. When Maya executes the eval line, it concatenates them all together and runs the resulting command as if it had been typed in.

I tried out the domino example. The following works pretty well for 1x3x6 dominoes spaced about 4 units apart:

for ($i = 1; $i < 31; $i++)
     eval("rotate -a 0 0 " + (-1*clamp(0,75,(5*frame - 25*$i))) + " pCube" + $i);
Hope that helps.

-Steve


Return to posts index

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