Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions plane propeller rotation (newbie question)

  • plane propeller rotation (newbie question)

    Posted by Greg Digenti on February 16, 2008 at 9:56 pm

    This will be embarrassingly simple for you expression wizards, but I’m new to expressions, so even the basics are tying my brain in knots. I searched the forums, but all the rotation questions I came across are much more involved than what I’m attempting to do.

    I have a propeller (in 3D space) whose rate of rotation is linked to a slider in another comp. I want it to spin nice and fast, then slow and come to a stop. Very simple.

    So the expression on the propeller is:

    spinControl = comp(“Flying Plane”).layer(“Prop Spin Control”).effect(“Prop Spinner”)(“Slider”);
    time * spinControl;

    The slider starts at 2000, which seems to be nice and fast (but why does this have to be such a high number? shouldn’t 360 be one complete rotation?), then at a certain point it starts down until it gets to 0. The problem occurs when it starts the decline… instead of just slowing down, it reverses direction, THEN slows to a stop.

    Shouldn’t time multiplied by a positive number always produce a clockwise rotation?

    Then I swapped out the second line of code for this:
    transform.zRotation.valueAtTime(time + spinControl);

    My thought was that it would take the value of the z rotation at that time and add the amount of the slider to it, then in the next frame do the same, and so on. But it just puts the propellor at a specific unmoving angle, so clearly I’m also not understanding the valueAtTime function, either.

    I know I’m going about this wrong, but I’m not sure where the problem lies, so any help would be appreciated.

    Greg Digenti replied 18 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Colin Braley

    February 18, 2008 at 2:42 am

    I think your main issue is that you are not realizing that expressions have no memory, meaning that an expression does not “remember” what value it had in a previous frame. This is why an expression (for rotation)such as:

    rotation + 15

    does not add 15 degrees to rotation each frame.

    If you want a better explanation of all this, check out the basic expressions tutorial on Dan Ebbert’s website http://www.motionscript.com.

    Anyway, now to solve your specific problem. I don’t have AE in front of me, but I think something like this should do the trick for your rotation expression:


    rotationIncrement = _____;//Link this to a slider and keyframe
    finalVal = 0;
    for( i = 0 ; i < time; i += thisComp.frameDuration() ){ finalVal += rotationIncrement.valueAtTime( i ); } finalVal

    Hopefully this makes sense and my code works okay. Enjoy.

    ~Colin Braley
    http://www.colinbraley.com

  • Greg Digenti

    February 19, 2008 at 2:13 am

    Okay, I see. I have a bit of javascript experience, and global variables are such a big part of how I typically write the code, this will take a bit of re-thinking.

    Thank you for your sample code, the frameDuration part is particularly helpful — though it only seemed to work when I removed the parenthesis after it. I checked out Dan Ebbert’s site, which was a great help, and ended up incorporating his exponential decay code to make the propeller start to slow once it was tripped by a Checkbox Control. (Your code did work, but it didn’t produce quite as smooth or realistic of a slowdown as that one.)

    Thanks again. Hopefully someday I’ll get to the point where my expression questions are challenging for you guys.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy