Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Need quick help with basic expression

  • Need quick help with basic expression

    Posted by Jason Brown on July 23, 2009 at 12:32 pm

    Hey Guys,

    I’m not very good @ expressions at all…so I need some quick help.

    I have 2 layers…a map in the background and a product in the foreground.

    I’m scaling…rotating and re-positioning the object and I want the map to subtly move in the background based on the objects movements.

    Problem is…I want it to basically move @ a percentage of the movement.

    ie – if the product scales from 60-80% (a 20% movement) the map should scale only 1-5%.

    I could do something similar with cameras and z space…but it seems it would be easier with expressions if I could figure it out.

    Any ideas?

    Thanks

    -Jason

    Curious Turtle replied 16 years, 10 months ago 3 Members · 6 Replies
  • 6 Replies
  • John Hammond

    July 23, 2009 at 2:25 pm

    could multiply the values by, say 0.1, which would reduce the values to 10% of the original

    e.g.

    y * 0.1

  • Curious Turtle

    July 23, 2009 at 2:25 pm

    There’s a number of ways to do this, and here’s one. It’s a bit (a lot) hacky and uses linear(), but it’ll do what you want it to do.

    targetLayer=thisComp.layer("your layer");
    targetMin=60;
    targetMax=80;
    endMin=1;
    endMax=5;
    temp=linear(targetLayer.transform.scale[0], targetMin, targetMax, endMin, endMax);
    [temp,temp]

    Just use the pickwhip to choose your “big” layer in the first line. Set your min and max scale values in the next four. I’ve used your values for the example.

    Hope that helps,
    Ben

    Curious Turtle Pro Video
    Training | Editing | Support

  • Jason Brown

    July 23, 2009 at 2:45 pm

    Tried the multiplication of .01 and the division by a small number.

    Didn’t react the way I wanted it to. Basically, it just made the value a division of .1 but scaled by the same amount.

    I’ll try Ben’s solution.

    Thanks guys.

    -Jason Brown
    Director of Photography
    Fusework Studios

    “I love the COW!”

  • Curious Turtle

    July 23, 2009 at 3:27 pm

    Slightly less hacky version:

    initialScale=100;
    percentScale=20;
    targetLayer=thisComp.layer("Your Layer");
    a=targetLayer.transform.scale[0];
    doIt=initialScale-percentScale+a/(100/percentScale);
    [doIt,doIt]

    Seems to work nicely. Set your target layer’s initial scale first, then you can set the percentage and offset.

    Cheers,
    Ben

    Curious Turtle Pro Video
    Training | Editing | Support

  • Jason Brown

    July 23, 2009 at 3:43 pm

    absolutely beautiful…works great.

    Now if I want to apply the same effect to rotation…and position, do I just need to change the word scale to position where applicable?

    Thanks so much. Looks really cool!

    -Jason

  • Curious Turtle

    July 23, 2009 at 4:29 pm

    Rotation you can pretty much use the same expression. Rotation only has to be one dimension, so just change the last line as well to:

    doIt

    Position is a little different. Here’s one for Position (maybe not elegant but it works):

    percentScale=20;
    targetLayer=thisComp.layer("Your Layer");
    initialTargetPos=targetLayer.position.valueAtTime(0);
    a=targetLayer.transform.position[0];
    b=targetLayer.transform.position[1];
    doItX=value[0]-initialTargetPos[0]+a/(100/percentScale);
    doItY=value[1]-initialTargetPos[1]+b/(100/percentScale);
    [doItX,doItY]

    It takes the target layer’s position value’s from the first frame as a baseline. You can change it if you need to in Line 3.

    Hope that helps,
    Ben

    Curious Turtle Pro Video
    Training | Editing | Support

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