Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions A Little Confused about Motionscript.com example

  • A Little Confused about Motionscript.com example

    Posted by David Bark on June 1, 2010 at 6:17 am

    Figured to teach myself expressions by reading up on it online. Went first to jjgifford, but was pretty overwhelmed in a very short time. Next went to motionscript.com, and that seem to be more my speed, but there’s a stuck point that I can’t figure out.

    While demonstrating the if/else expression possibilities, Dan provides an example in which the opacity of an object is determined by it’s rotation. The expression is:

    if (rotation < 180) 100 else 50 That works fine the first time around, but after the first revolution, the object remains at 20% opacity. On the web page, his sample object is continuously rotating and changing opacity every 180 degrees. As far as I can tell, there isn't an index parameter for rotation, like [0] would by the revolutions and [1] would be the degrees, so once the object passes the first complete rotation, it's not going back to 1 degree, but rather 361 degrees, if that makes sense. Obviously this isn't a real world problem, but I'm just trying to understand. I suppose the most logical explanation is that the continuously rotating (and opacity changing) example is just that, an example, maybe duplicated, sequenced layers or something. (You know, a couple weeks ago I wouldn't have known what a duplicated, sequenced layer was!) Anyway, any thoughts that would help clear up my confusion would be appreciated. Thanks! David Bark Lightshine Productions

    Dan Ebberts
    replied 15 years, 11 months ago
    3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 1, 2010 at 5:29 pm

    I probably just looped the movie after 1 revolution. To get that behavior, you just need to to this:

    if (rotation%360 < 180) 100 else 50 Dan

  • David Bark

    June 1, 2010 at 5:54 pm

    Thanks!

    David Bark
    Lightshine Productions

  • Hannes Paulsson

    June 2, 2010 at 1:28 pm

    This looks interesting, would you mind explaining a bit about the %-thing, how and when it’s used?

  • Dan Ebberts

    June 2, 2010 at 2:51 pm

    % is the JavaScript modulus operator. It gives you the remainder from a division operation. So 12%5 is 2, 7.3%6 is 1.3, and so on. It’s very useful for taking a value that steadily increases (like time) and turning it into repeating ramp. So, for example, time%10 would give you a value that ramps from 0 to ten and then starts over at 0 (as time moves beyond 10). In the rotation case, as the value increases above 360, rotation%360 starts over at 0 every 360 degrees. It helps to look at it in the graph editor.

    Dan

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