View Full Version : How to make an attribute that drives the rotation speed of an object?

11 November 2007, 05:52 AM
Ok, I have a very basic understanding of expressions and I'm trying to learn more. One thing I need/want to do is setup an attribute called "speed" that dictates how fast an object rotates on a robot. It's basically just like a rotary toothbrush or something like that.

Anywho, upon searching, I've found similar questions asked and haven't found a straight answer. From what I've read, the following types of expressions have been suggested:

pCylinder1.rotateY = pCylinder1.speed * 360 * time; or
pCylinder1.rotateY = frame * 5 *pCylinder1.speed;

where .speed is the speed attribute that I want to drive the object's rotation. This works somewhat, but keying the speed from say 0-5-0 makes the object rotate forwards and then backwards til it reaches zero.

Basically, I'd like to be able to key the speed from 0-10(or whatever I set the limit at) and then be able to key it back to zero but just have it slow down to a standstill and not rotate all the way back to 0 degrees.

I hope that makes sense and it seems like it should be easy enough. Thanks!

11 November 2007, 11:29 AM
If you consider the speed attribute as the amount of change to the rotation then your expression would look like this.
pCylinder1.rotateY += pCylinder1.speed;
It means that at each frame the pCylinder1.speed value is added to the current pCylinder1.rotateY value. You can animate pCylinder1.speed however you wish. To make this work the same way each time you play the animation you would need to always rewind to the start frame where your expression would need to initialize the value of pCylinder1.rotateY.
if(frame==1) pCylinder1.rotateY = 0;
And if you plan to render on multiple machines, or to start the render midway through, you should bake the animation prior to rendering.

-- David

CGTalk Moderation
11 November 2007, 11:29 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.