Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Use A Null Slider To Interpolate Between Series Of Positions

  • Use A Null Slider To Interpolate Between Series Of Positions

    Posted by Ludwig Sweet on May 8, 2019 at 1:22 am

    I have a layer that I’d like to smoothly move between a series of pre-set x,y positions (2, 54)(-4, -174)(0, -12)(8, 190) etc. Obviously I can keyframe each position manually, but I’d like to be able to use a parent “master slider” to interpolate between each x,y value.

    For example:

    I’d like to be able to enter a value of “1” into the “master slider”, and have the child layer’s position move to 2, 54; then enter a value of “2” into the “master slider” and have the child layer move to position (-4, -174); then enter a value of “3” into the “master slider” and have the child layer move to position (0, -12); then enter a value of “1” (again) into the “master slider” and have the child layer move back to position (2, 54)..etc…

    In this example I use 3 different x,y positions for the sake of simplicity, but ultimately I’d like to be able to smoothly move between 100+ different positions using this method.

    Also, it’s important that whatever script I ultimately use isn’t temporal-based/timeline-based, but is based purely on x,y positions. I’m new to scripting, but I’m hoping there’s an elegant solution.

    Kalleheikki Kannisto replied 6 years, 12 months ago 3 Members · 3 Replies
  • 3 Replies
  • Christian Geijer

    May 8, 2019 at 9:38 am

    This maybe isn’t exactly what you want but it might help you on your way.

    One way could be to create a .json-file with all the different positions mapped to the corresponding slider value like this:
    {
    "positions": {
    "1": {
    "x": 2,
    "y": 54
    },
    "2": {
    "x": -4,
    "y": -174
    }
    }
    }

    Place the .json-file (here named data.json) in your composition and then, with the value from Master slider (in my example placed on a null layer named “Control”), change the position of the object you want to move around with an expression that looks something like this:
    id = thisComp.layer("Control").effect("Master slider")("Slider").toString;
    x = thisComp.layer("data.json").source.sourceData.positions[id].x;
    y = thisComp.layer("data.json").source.sourceData.positions[id].y;
    [x,y]

    This, however, only works with the slider being set to whole numbers that you also have defined in data.json and does not work if the slider animates between the different values. You maybe can define the first and second positions and use linear() to animate between them, but I’m not sure how you’d want that to work in your specific case.

  • Kalleheikki Kannisto

    May 8, 2019 at 2:01 pm

    Basically the same matter as discussed here. No ready expressions, but the basic methodology is there.

    https://forums.creativecow.net/thread/227/41791

    If the transition time is always the same — which it would have to be if you use just a single slider — you can simplify this by looping back from the current frame for the number frames that cover the transition and checking if the hold keyframe value has changed during that time. If it has, you can calculate the progress between the two positions (read from an array) from how many frames back the value changed (in relation to the full transition time).

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Kalleheikki Kannisto

    May 8, 2019 at 2:37 pm

    For the simpler implementation with fixed transition time and one slider (using hold keyframes), slider on layer “controls”.

    Position expression:

    pos_array = [[2, 54],[-4, -174],[0, -12],[8, 190]]; // predefined positions array
    tt = 10; //transition time in frames
    cv = thisComp.layer("controls").effect("Slider Control")("Slider").value; //current slider value
    tp = 0; // transition progress default
    for (i=0; i

    Kalleheikki Kannisto
    Senior Graphic Designer

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