Forum Replies Created

Page 141 of 1081
  • Try replacing the last line with:

    clamp(d[0] + d[1],-20,20);

    Dan

  • Dan Ebberts

    May 27, 2020 at 3:18 pm in reply to: Trigger In and Out animation with comps markers

    Something like this should work as long as the markers are farther apart than the keyframes:


    m = thisComp.marker;
    t = 0;
    if (numKeys > 1 && m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n == 1)
    t = key(1).time + time - m.key(1).time
    else if (n == 2)
    t = key(2).time - (time - m.key(2).time);
    }
    valueAtTime(t)

  • If I understand how you have this set up, you need to adjust the time by the offset of the precomp’s start time within the main comp, like this (not tested):

    C = comp(“Slide3”);
    L = C.layer(thisComp.name);
    p = C.layer(“SW_Robot_1”).transform.position;
    d = p.valueAtTime(time + L.startTime) – p.valueAtTime(time + L.startTime – .1);

    (d[0] + d[1]);

    Dan

  • Dan Ebberts

    May 26, 2020 at 7:51 pm in reply to: Trigger In and Out animation with comps markers

    If you want the whole animation triggered at each marker (rather than centered at each marker), it would be more like this:


    m = thisComp.marker;
    t = 0;
    if (numKeys > 1 && m.numKeys > 0){
    d = key(2).time - key(1).time;
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n > 0){
    tm = time - m.key(n).time;
    if (tm < d){
    t = linear(tm,0,d,key(1).time,key(2).time);
    }else{
    t = linear(tm,d,d*d,key(2).time,key(1).time);
    }

    }
    }
    valueAtTime(t)

    Dan

  • Dan Ebberts

    May 26, 2020 at 6:45 pm in reply to: Trigger In and Out animation with comps markers

    I’m not sure if this is what you’re after, but give it a try:


    m = thisComp.marker;
    t = 0;
    if (numKeys > 1 && m.numKeys > 0){
    d = key(2).time - key(1).time;
    tm = m.nearestKey(time).time;
    if (time < tm){
    t = linear(time,tm-d,tm,key(1).time,key(2).time)
    }else{
    t = linear(time,tm,tm+d,key(2).time,key(1).time)
    }
    }
    valueAtTime(t)

    Dan

  • Dan Ebberts

    May 23, 2020 at 2:42 am in reply to: Link two markers to two keyframes

    I haven’t test this, but I think it would be:


    if (marker.numKeys > 1){
    t1 = marker.key(1).time;
    t2 = marker.key(2).time
    linear(time,t1,t2,0,t2).toFixed(0);
    }else
    0

    Dan

  • Dan Ebberts

    May 23, 2020 at 12:36 am in reply to: Link two markers to two keyframes

    >reverse this so it is the other way round

    What do you mean by that, exactly?

  • No, like this:


    C = comp("Scene 01");
    ctrl = C.layer("controls").effect("Slider Control")("Slider");
    L = C.layer(thisComp.name);
    val = Math.round(ctrl.valueAtTime(time+L.startTime));
    val == index ? 100 : 0

    Dan

  • These days, that last line should be modified:

    val == index ? 100 : 0

    Dan

  • It’s tricky, but if your graphs are true functions of x (no instances of multiple y values for the same x) you can probably do it with an iterative solution like this simple binary search:


    iterations = 12;
    L = thisComp.layer("Path 1");
    p = L.content("Shape 1").content("Path 1").path;
    xc = thisComp.layer("Cursor").transform.position[0];
    p0 = L.toComp(p.pointOnPath(0));
    p1 = L.toComp(p.pointOnPath(1));
    if (xc < p0[0]){
    p0;
    }else if (xc > p1[0]){
    p1;
    }else{
    lower = 0;
    mid = .5;
    upper = 1.0;
    for ( i = 0; i < iterations; i++){
    pCur = L.toComp(p.pointOnPath(mid));
    if (pCur[0] == xc) break;
    if (pCur[0] > xc){
    upper = mid;
    }else{
    lower = mid
    }
    mid = (upper+lower)/2;
    }
    [xc,pCur[1]]
    }

    Bumping the iterations value should make it more accurate at the expense of rendering performance.

    Dan

Page 141 of 1081

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