Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Checkbox + Interpolation Problem

  • Checkbox + Interpolation Problem

    Posted by Nathan Clark on April 17, 2009 at 9:26 am

    Hey all,

    I am struggling getting the following to work

    Aim:

    • Have 2 null objects which the camera can potentially autofocus on,
    • Use a checkbox to switch between the 2 values,
    • Have a 5 second transition between the 2 values.

    Problem:

    • The interpolation starts from ‘frame 0’ instead of from where the checkbox keyframe is.

    Code:

    target1 = thisComp.layer(“Focus”);
    v1 = target1.toWorld(target1.anchorPoint) – toWorld([0,0,0]);
    v2 = toWorldVec([0,0,1]);
    v3 = dot(v1,v2);

    target2 = thisComp.layer(“ForceFocus”);
    b1 = target2.toWorld(target2.anchorPoint) – toWorld([0,0,0]);
    b2 = toWorldVec([0,0,1]);
    b3 = dot(b1,b2);

    if (thisComp.layer(“Focus”).effect(“FocusNull”)(“Checkbox”)==true) {
    ease(time, 0, 5, b3, v3);
    } else {
    ease(time, 0, 5, v3, b3);
    }

    If anyone can help out with this it wold be much appreciated.
    I am on a fairly tight timeline with this one and could really benefit from somebody’s knowledge.

    Kinds regards

    Nathan

    Dan Ebberts replied 17 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    April 17, 2009 at 5:06 pm

    It’s hard to see exactly what you’re doing, but I think you need to involve the times of your keyframes. Part of your code would be structured like this:

    t = thisComp.layer(“Focus”).effect(“FocusNull”)(“Checkbox”).key(1).time;

    if (time < t){ b3 }else{ linear(time,t,t+5,b3,v3) } Dan }

  • Nathan Clark

    April 18, 2009 at 12:42 pm

    Hey Dan,

    Thanks for your fast response!
    After having the night to think about it I have come to realize I could simplify my needs and even improve the function of my expression..

    All I need is a slider that will control the interpolation between my 2 values (v3 and B3)

    So for example if the Slider is at zero, my value will be v3 and if slider is 100 my value will be b3.

    Is this possible?

    Again, Thank You very much for you attention!

    Kind Regards,

    Nathan

    (PS.
    Please let me know if you would like me to elaborate on the context of this expression in relation to my project.)

  • Nathan Clark

    April 18, 2009 at 1:24 pm

    Hey Dan

    Okay Wow,
    Its so simple
    I worked it out!!
    when the interpolation methods finally made sense it was an amazing moment!
    I was having difficulty understanding the relationship between the inputs but then suddenly it all clicked!
    wow, what a powerful function!

    I am on the right track now

    Thanks for you help and time!

    Best wishes

    Nathan Clark

    (PS.
    is it normal to get so excited about a line of code. I am smiling so hard my cheeks hurt… and over an expression… what a geek).

  • Dan Ebberts

    April 18, 2009 at 3:52 pm

    Getting a piece of code to work is a pleasure that’s hard to explain to anyone that hasn’t done it. Welcome to the club. 🙂

    Dan

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