Forum Replies Created

  • Emmett Fraser

    October 27, 2016 at 7:10 pm in reply to: Time remapping w/o affecting a bounce expression

    Thanks for the response Dan!

    I’ve gone the route of working on my (rather, your) bounce expression and I can’t seem to make it work. My code is pasted below.

    What I did was create a ts variable that pulls from my “time scale” control. If time scale = 2 everything should go twice as fast (except for the bounce). Then I divided the key(n).time values by ts, thinking that would make the bounce expression kick in twice as early.

    Where I think I get out of my depth is in the velocity calculation. I divided key(n).time by ts in the velocityAtTime code but that didn’t seem to help.

    Finally I modified the else expressions to adjust with the time scale as well (but I’m 99% sure that’s not the problem.)

    Any help you could provide would be greatly appreciated!

    e = .7;
    g = 2500;
    nMax = 9;
    ts = comp("_controller").layer("Controller").effect("time scale")("Slider")

    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time/ts > time) n--;
    }
    if (n > 0){
    t = time - key(n).time/ts;
    v = -velocityAtTime(key(n).time/ts - .001)*e;
    vl = length(v);
    if (value instanceof Array){
    vu = (vl > 0) ? normalize(v) : [0,0,0];
    }else{
    vu = (v < 0) ? -1 : 1;
    }
    tCur = 0;
    segDur = 2*vl/g;
    tNext = segDur;
    nb = 1; // number of bounces
    while (tNext < t && nb <= nMax){
    vl *= e;
    segDur *= e;
    tCur = tNext;
    tNext += segDur;
    nb++
    }
    if(nb <= nMax){
    delta = t - tCur;
    value + vu*delta*(vl - g*delta/2);
    }else{
    easeIn(time,0,1/ts,[400,200],[690,200])
    }
    }else
    easeIn(time,0,1/ts,[400,200],[690,200])

  • Hey Jorge, just wanted to let you know where I ended up. Your snippet was really helpful to get me started and send me down the right path. Once I got yours working I wanted to change it so that the timing of the change could be controlled by a marker on the layer.

    After a lot of trial and error I ended up with this!

    I pasted the code in the Stroke Width property and made a slider called “spark width”.

    Anyways, thanks for your help!

    time_to_marker = Math.abs(time - thisLayer.marker.nearestKey(time).time)*5
    easeOut(time_to_marker,comp("_controller").layer("Controller").effect("spark width")("Slider"),2)

  • Thanks Jorge, I’ll give this a try!

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