Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding “Time Offset” to a selected layer via the Layer control expression

  • Adding “Time Offset” to a selected layer via the Layer control expression

    Posted by Brett Morris on November 25, 2013 at 3:22 pm

    Hi All,

    I’ve come up against a wall Im hoping someone may be able to help me get over. I’ve got a camera rig which I have a small expression control set up on a null. The controls null has a ‘Target active’ (checkbox), ‘Target layer’ (layer control) and ‘Time offset” (slider control).

    The point of the control is a have the ability to easily select between layers within the comp from the layer control for the camera to target, then the ability to add time offset to delay any animation on the camera following the selected layer. While also easily deactivating the target active to have the camera free from the targeting system.

    My expression so far works when I have just the layer control controlling the selected layer but when I add the time offset into the equation, its error city.

    Can anyone help me out? I know its got to do with the array of the selected layer, though Im not entirely sure how to use that information within the valueAtTime(t) in this current set up.

    Any help Id greatly appreciate. Thanks!

    try{
    L = thisComp.layer("Null 10").effect("Layer Control")("Layer");
    target = L.toWorld(L.anchorPoint);
    }catch(err){
    target = value;
    }

    tarActive = thisComp.layer("Null 10").effect("Checkbox Control")("Checkbox");
    tOffset = thisComp.layer("Null 10").effect("Slider Control")("Slider");
    t = time + tOffset;
    POI = target.position.valueAtTime(t);

    if (tarActive==1) {POI} else {value}

    Brett Morris replied 12 years, 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • Darby Edelen

    November 25, 2013 at 5:11 pm

    [Brett Morris] “POI = target.position.valueAtTime(t);”

    The first thing that jumps out at me is that “target” is an array (not a layer) so it shouldn’t have a “position” member.

    POI = L.toWorld(L.anchorPoint, t);

    I believe that should get you closer, but you’ll need to make sure that “L” indeed exists (as it resides in a try{} statement it may not). I’d recommend re-ordering your expression so that the try{} statement is after the variable declarations of tarActive, tOffset and t.

    Then I’d replace this line in the try{} statement:

    target = L.toWorld(L.anchorPoint);

    With the above line:

    POI = L.toWorld(L.anchorPoint, t);

    Darby Edelen

  • Brett Morris

    November 25, 2013 at 5:52 pm

    Thanks Darby, lightning fast on that response!

    That makes sense, I’ll give it run tonight and get back to you with how it goes.

    Thanks again!

  • Brett Morris

    November 26, 2013 at 3:41 pm

    Darby you brilliant man, it worked!

    I ended up with the below expression….

    If you’re ever in LA/or based in LA I’ve got to buy you a beer for that one.

    Cheers!

    POI = value;
    tarActive = thisComp.layer("Controls").effect("Target Active")("Checkbox");
    tOffset = thisComp.layer("Controls").effect("Time Delay")("Slider");
    t = time + tOffset;

    try{
    L = thisComp.layer("Controls").effect("Target")("Layer");
    POI = L.toWorld(L.anchorPoint, t);
    }catch(err){
    target = value;
    }

    if (tarActive==1) {POI} else {value}

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