Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 2nd part of conditional statement not working

  • 2nd part of conditional statement not working

    Posted by David Cabestany on September 20, 2022 at 2:27 pm

    I’m trying to use the keyframes for position to drive other parameters, rotation in this case, but only for part of the position animation.
    The first part, from kf1 to kf2 works fine, but when the object moves to kf3 it is also rotating, which I do not want.

    I added a part of the condition that states that if the kf is bigger than 2 then the value should be 0, but as I see the object moving from kf2 to kf3 I see the rotation parameter still following the linear expression instead of defaulting to 0 as I want it to happen.

    Any help is greatly appreciated.

    p=transform.position[0];

    k1=transform.position.key(1).value[0];

    k2=transform.position.key(2).value[0];

    n = 0;

    if (marker.numKeys > 0){

    n = marker.nearestKey(time).index;

    if (marker.key(n).time > time) n–};

    if

    (n<2)

    {

    x=linear(p,k1,k2,value,0);

    }

    if

    (n>2)

    {x=0}

    x

    ;

    Dan Ebberts
    replied 2 years, 7 months ago
    2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 20, 2022 at 4:30 pm

    A couple of things–you seem to be mixing the use of markers and position keyframes–you didn’t mention that in your description, and it’s not clear how that should work. Also, you don’t account for the condition where n is exactly 2, so that could be a problem.

  • David Cabestany

    September 20, 2022 at 4:40 pm

    Thanks Dan, the marker/keyframe mixup is definitely unintended, I only want to use keyframes for this.

    Basically a linear animation between keyframes 1 and 2 and then 0 after that.

  • Dan Ebberts

    September 20, 2022 at 6:39 pm

    Maybe like this:

    p=transform.position;
    t1 = p.key(1).time;
    t2 = p.key(2).time;
    linear(time,t1,t2,value,0)

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