Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions start/stop expression at specific time

  • Dan Ebberts

    April 16, 2014 at 8:46 pm

    I think it would look like this:


    beginTime = 1;
    endTime = 30;

    yOrigin = 520;
    seedRandom(index,true);
    yDelta = random(-10,10);

    f = timeToFrames(time);

    if (f <= beginTime){
    d = 0;
    }else if (f <= endTime){
    d = f - beginTime;
    }else{
    d = endTime - beginTime;
    }
    yNew = yOrigin + d*yDelta;
    [value[0],yNew]

    Although, if you wanted to key it to the layer’s in point, something like this might be better:


    dur = 30;

    yOrigin = 520;
    seedRandom(index,true);
    yDelta = random(-10,10);

    f = Math.max(timeToFrames(time-inPoint),0);
    d = (f < dur) ? f : dur;
    yNew = yOrigin + d*yDelta;
    [value[0],yNew]

    Dan

  • Cameron Walser

    April 16, 2014 at 9:24 pm

    Awesome thank you – one more quick question Dan –

    1) How in the world do you have time to answer all these questions?!
    🙂

  • Dan Ebberts

    April 16, 2014 at 9:31 pm

    Sorry, no time to answer… 😉

  • Cameron Walser

    April 17, 2014 at 7:18 pm

    Dan maybe you’ll know the answer to this one –
    I’ve made a functional comp with the expression, finally, and the expression references Expression Sliders on a null layer. So after I duplicate the layer a thousand times, I can simply adjust the sliders on the one layer. Here’s the question – what if I want to change the expression itself? Do I have to re-duplicate the layer 1000 times? Or is there some way to reference a “Master” expression?

    Latest expression posted just FYI

    dur = 1;
    x = thisComp.layer("NULL PARAMETERS").effect("X_Origin")("Slider");
    f = (timeToFrames(time));
    yOrigin = 500;
    seedRandom(index,true);

    y = linear(time, inPoint, inPoint + dur, thisComp.layer("NULL PARAMETERS").effect("Y_Origin")("Slider"), (thisComp.layer("NULL PARAMETERS").effect("Y_Origin")("Slider") - (random (thisComp.layer("NULL PARAMETERS").effect("Least")("Slider"), thisComp.layer("NULL PARAMETERS").effect("Most")("Slider")) ) ) );

    [x, y]

  • Dan Ebberts

    April 17, 2014 at 7:24 pm

    There are hacks for a master expression, like putting it in a hidden text layer, but it’s really inefficient. Faster than re-duplicating all the layers would be to change the expression in one layer, make sure that property is selected, Edit > Copy Expression Only, select all the other layers, Edit > Paste.

    Dan

  • David Chasterfield

    January 14, 2015 at 7:31 am

    hello my friend 😉
    i been trying to pick whip the position of layer A with layer B at second 2… so far i tried a few simple expressions coz I’m new at expressions but i failed , nothing worked for me… here one of them :

    timeToStart=2;
    if (time >=timeToStart)
    {
    thisComp.layer(“Shape Layer 1″).transform.position
    }

    as you can see there in the middle all i do is pick whip the position of the layer A to layer B , trying to get it to follow starting from second 2 …i tried this for the rotation and it did work , but for the position it gives me this error ” expression result must be of dimension 2 , not 1. “…
    so if u can help or maybe write me an example i can work with , that would be really great , thanks in advance

  • Dan Ebberts

    January 14, 2015 at 7:48 am

    The expression needs to provide a legal position value before the start time. I’m not sure if this does what you want, but it should avoid the error:

    timeToStart=2;
    if (time >=timeToStart)
    {
    thisComp.layer(“Shape Layer 1”).transform.position
    }else{
    value
    }

    Dan

  • David Chasterfield

    January 14, 2015 at 7:53 am

    it did got rid of the error and it did what i wanted ^^
    works like a charm ! thanks a lot my friend !

  • David Chasterfield

    January 14, 2015 at 8:25 am

    actually I’m having another problem now , it didn’t work with that shape layer because of the anchor point , so i used a null object and parented it to that shape layer and then used its position for the expression , but when second 2 comes the layer A the one i parented its position to the null’s , it don’t really follow it , it goes in some random position and it don’t even move lol , thought its parented !

  • Dan Ebberts

    January 14, 2015 at 8:31 am

    The new expression will probably need to look like this:

    timeToStart=2;
    if (time >=timeToStart)
    {
    thisComp.layer(“Null 1”).toComp([0,0,0])
    }else{
    value
    }

    Dan

Page 3 of 5

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