Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Speed ​​control with parallax

  • Speed ​​control with parallax

    Posted by Adrien Menielle on July 26, 2024 at 12:59 pm

    Hello, I use the well-known expression of Dan Ebbert to control the scrolling of a layer in a composition. This expression is:

    spd = thisComp.layer("SPEED CONTROL").effect("Layer speed control")("Slider");
    n = spd.numKeys;
    if (n > 0 && spd.key(1).time < time){
    accum = spd.key(1).value*(spd.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (spd.key(i).time > time) break;
    k1 = spd.key(i-1);
    k2 = spd.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
    }else{
    accum = spd.value*(time - inPoint);
    }
    value + accum

    Now, I would like to add a parallax effect and add a second layer behaving exactly the same way but 20% faster than the one in the background. And I don’t know where I can enter this factor in the expression. Can you help me please ?

    I first tried to connect the controller at the beginning of the expression to another controller, itself connected by expression to the first with an “x 1.2” but suddenly I have a problem on the deceleration that Dan mentions at the beginning of his article here: https://www.motionscript.com/articles/speed-control.html

    Thanks

    Nils Hammers replied 1 year, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Nils Hammers

    July 26, 2024 at 8:28 pm

    2D parallax shouldn’t be so hard to achieve by much more simpler means, aren’t you over-complicating the solution? Unless it is 3D, where the speed is calculated based on camera parameters, for 2D it is you who decides how much the second layer is moving faster/slower than the first one, i.e. same

    value + layer1.position * 1.2 ;

    may suffice.
    If you necessarily want to use Dan’s expression, then the dirty solution might be to have it in every layer and multiply-by-expression the Layer speed control slider’s value instead. Just choose which layer will set the “default” speed, and link all the other layers to it with different factors.

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