Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simple if/else statement problem

  • Simple if/else statement problem

    Posted by Nick Rosier on April 27, 2010 at 1:38 pm

    Hi,

    I’m creating an expression that controls the orientation of a layer.

    x=transform.orientation[0];
    y=transform.orientation[1];
    z=radians_to_degrees(Math.atan(distanceA/distanceB));

    //have written distanceA and B to save writing down calculation

    if (z >= 270){
    [x,y,(z-180)];
    }else{ [x,y,z]; }

    So basically, the layer this code is attached to points to another layer (have only applied this to the z orientation as you can see). The if statement stops the z angle jumping from 89.99 to 270.

    Thing is, this if statement didn’t work.. the jump happened anyway.

    I had to make a null, and put

    x=transform.orientation[0];
    y=transform.orientation[1];
    z=radians_to_degrees(Math.atan(distanceA/distanceB));
    [x,y,z];

    in the orientation, then reference these values in the visible layer:

    x=null's x orientation;
    y=null's y orientation;
    z=null's z orientation;

    if (z >= 270){
    [x,y,(z-180)];
    }else{ [x,y,z]; }

    for it to work.

    Why’s this? Is there a shorter way of doing this?

    Cheers
    Nick

    Nick Rosier replied 16 years ago 1 Member · 1 Reply
  • 1 Reply
  • Nick Rosier

    April 27, 2010 at 1:55 pm

    oh so yeah you can pretty much do this by parenting the coords of a corner pin to the position of the origin layer and target layer.

    but would be interesting to know why I had to apply the expression to a null before the if statement would work anyway!

    thanks

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