Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking Null position to 3 other to Control Position with Checkbox Constraints

  • Linking Null position to 3 other to Control Position with Checkbox Constraints

    Posted by Sandro Maia on March 9, 2025 at 12:52 am

    Hi,

    Is it possible to link the position of a null object (let’s call it “Null1”) to 3 other nulls, where each of these nulls can independently influence Null1’s position? Additionally, I’d like to add a checkbox control on Null1 that allows me to disable the influence of null 2.

    For example, if the checkbox for “Null2” is unchecked, Null2 should no longer affect Null1’s position. However, if Null2 was previously influencing Null1 and I then uncheck the checkbox, Null1 should remain in its last position rather than snapping back or changing unexpectedly. Also bonus if I can keep manual control over null 1

    I’ve tried different approaches, but I haven’t been able to make Null1 stop moving when I uncheck the box and then move Null2.

    Would you have any suggestions on how to achieve this?

    Dan Ebberts replied 2 weeks, 2 days ago 2 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    March 9, 2025 at 12:59 am

    In what way to the other nulls “influence” Null 1’s position? What does that mean, exactly?

  • Dan Ebberts

    March 9, 2025 at 1:24 am

    If you want Null 1 to move based on the relative movement of the other nulls, the other nulls need reference points. One way to do it is to keyframe their movement and Null 1 can take on movement of the other nulls that has occurred since time = 0. That would look something like this:

    n2 = thisComp.layer("Null 2");
    n3 = thisComp.layer("Null 3");
    n4 = thisComp.layer("Null 4");
    includeN2 = effect("Checkbox Control")("Checkbox") == 1;
    d2 = n2.position - n2.position.valueAtTime(0);
    d3 = n3.position - n3.position.valueAtTime(0);
    d4 = n4.position - n4.position.valueAtTime(0);
    val = value + d3 + d4;
    if (includeN2) val += d2;
    val

    Null 2’s movement only gets included if the checkbox is on. If you want to animate the checkbox, that’s a much more complicated proposition…

  • Sandro Maia

    March 9, 2025 at 9:14 am

    Hi Dan,

    What I mean is that all three nulls should be able to move Null1 as if it were a regular null. However, I want to add a checkbox that allows me to toggle whether Null2 can control Null1’s position. The checkbox doesn’t need to be keyframed, although that would be a plus if it could. But this should all work with no keyframes at all and if I want to keyframe the position of any given null I would want that possibility. Would this be possible?

    Let me know if that makes sense!

  • Dan Ebberts

    March 9, 2025 at 12:43 pm

    >as if it were a regular null.

    I have to confess, that I have no idea what that means. Are you talking about parenting?

  • Sandro Maia

    March 9, 2025 at 1:31 pm

    Sorry Dan, English is not my first language, so it might be difficult to translate ideas, if it helps this is what i tried:

    It mostly works, if i uncheck the checkbox the layer stops following Null 1, the problem is that when i check the box for it to follow again, the layer has an offset and its moving more than it should.


    var checkbox = effect("Checkbox Control")("Checkbox");

    var null1 = thisComp.layer("Null 1").transform.position;

    var null2 = thisComp.layer("Null 2").transform.position;

    var null3 = thisComp.layer("Null 3").transform.position;


    // Always follows Null 2 and Null 3 wether checkbox is on/off


    if (checkbox == 1) {

    // If checkbox is checked, follow Null 1 and Null 2 and Null 3

    null3 + (null1 - null2)

    } else {

    // If checkbox is unchecked, follow Null 2 and Null 3

    null3 + (null2 - null1)

    }

  • Sandro Maia

    March 9, 2025 at 1:32 pm
  • Dan Ebberts

    March 9, 2025 at 1:55 pm

    Ah, OK. I don’t think you’ll ever be able to set it up so that the position doesn’t change instantly when you toggle the checkbox to bring the influence of Null 2 in or out. There’s no way for the expression to know the history of the checkbox (unless it’s keyframed or controlled by an expression).

  • Sandro Maia

    March 9, 2025 at 2:20 pm

    Thats unfortunate. Okay thank you. Do you think its possible to fix that offset of the Null 1 when the checkbox is on? I can’t for the life of me figure it out…

  • Dan Ebberts

    March 9, 2025 at 2:34 pm

    I don’t understand your formula. Why does having the checkbox on flip the effect of null1 and null2? It seems like it should just remove the effect of null2.

  • Sandro Maia

    March 9, 2025 at 8:49 pm

    I see your point, but if i remove null2 the layer jumps position to another place in the comp.

Page 1 of 2

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