Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How do I initiate a timed animation within an expression?

  • How do I initiate a timed animation within an expression?

    Posted by Thomas Horne on January 6, 2010 at 8:56 pm

    Hello,

    I currently have an AECS3 expression that uses a control layer’s Red channel values to determine the y rotation of a 3d object (code attached).

    It’s working great, but what I’d like to do is instead of having it switch instantly to 180 degrees when the condition is met, to initiate a six-frame rotation to 180 degrees.

    How do I do that?

    Thanks,

    Thomas Horne

    target = thisComp.layer("controller Comp 1");
    color = target.sampleImage([transform.position[0],transform.position[1]], [.5,.5], true, time);

    if (color[0] == 0){
    0;
    }else{
    180;
    }

    Thomas Horne replied 16 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 6, 2010 at 9:43 pm

    I haven’t had time to test this code (so buyer beware) but it will be something like this, where you loop back through time, frame by frame, to see how long the red value has been greater than zero. Then you just multiply the number of frames (maximum 6) times 30 to get your result.

    target = thisComp.layer(“controller Comp 1”);
    color = target.sampleImage([transform.position[0],transform.position[1]], [.5,.5], true, time);

    if (color[0] == 0){
    0;
    }else{
    f = thisComp.frameDuration;
    for (i = 1; i <= 6; i++){ color = target.sampleImage([transform.position[0],transform.position[1]], [.5,.5], true, time-i*f); if (color[0] > 0) break;
    }
    i*30;
    }

    Dan

  • Thomas Horne

    January 6, 2010 at 10:01 pm

    Thanks so much for your time Dan! – doesn’t seem to be working though. objects get frozen at half rotation, or click back and forth, etc.

    I did make sure that I copied it right, and tried modifying things, to no avail. I’ll keep messing around on this end, if you have any more moments to spend on this, I would be extremely grateful!

  • Dan Ebberts

    January 6, 2010 at 10:44 pm

    Yes, I see a few problems. Try this:

    target = thisComp.layer(“controller Comp 1”);
    color = target.sampleImage([transform.position[0],transform.position[1]], [.5,.5], true, time);

    if (color[0] == 0){
    0;
    }else{
    f = thisComp.frameDuration;
    for (i = 1; i <= 6; i++){ t = time-i*f; p = transform.position.valueAtTime(t); color = target.sampleImage([p[0],p[1]], [.5,.5], true,t); if (color[0] == 0) break; } Math.min(i,6)*30; } Dan

  • Thomas Horne

    January 7, 2010 at 12:49 am

    Dan,

    You are the MAN. I guess everyone already knows that though! 🙂 Thanks so much for all the expression awesomeness over the years.

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