• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Proximity expression whilst maintaining same distance to other comps?

Community Beginner ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

Please help,

I’m using a proximity effector (https://www.youtube.com/watch?v=eEEd-YuBHn0) to scale up some comps in a carousel as the pass through the centre of the composition. So far so good. However, I really need the distances between the comps to stay the same as this happens, rather than overlapping.

It’s something that I can’t key frame individually as they’ll be loads of comps and I need to alter the speed of the carousel without having to keyframe the individual comps left/right every time... which will drive me insane. 

Worth mentioning that I’m using squares in the example but I’ll be using comps of different widths in the final version. 

I’ve spent an entire day trawling the web for some clues on how to do this but I’ve had no luck. 

If anyone could give me some pointers I would be most grateful. 

Thanks so much in advance.

prox_test.gif

 

TOPICS
Expressions

Views

255

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

If you know the scale, you know how many pixels you need to add. The formula is no different, just the values. It's just another linear() for the position:

 

X=value[0]+linear(distance, minDist, maxDist, 0, offset);

Y=value[1];

 

[X,Y]

 

Just fill in the values and variables as needed and experiment around.

 

Mylenium 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

This is a cool challenge!

There may be a more elegant way to do this, but I think this rig setup could be a good starting point.

I thought of this as a chain of layers that you can control with a spacing slider - so you'll need to set it up with a control layer (probably a null) that has a slider effect on it called "spacing".

 

Then set up your comp so that all the layers in the carousel are in ascending order (or uh, so the next layer is under the previous in the timeline). If you can't get them all in one chunk, just pay attention to how I call the layer index in the below expression.

Apply this to the position property of each layer after the first carousel comp:

 

var prevComp = thisComp.layer(index-1)       

//change the 1 to whatever increment you need to get to the prev comp's index

var spacing = thisComp.layer("Control").effect("spacing")("Slider") 
var scaleFactor= thisLayer.transform.scale[0]; 

//this will help accounts for how much the width changes based on the scale
var scaleFactorPrev = prevComp.transform.scale[0];

var prevWidth = prevComp.width*(scaleFactorPrev/100);
var prevPosition = prevComp.transform.position[0];
var currentWidth = thisLayer.width*(scaleFactor/100);


var x = (prevPosition+prevWidth/2) + currentWidth/2 + spacing;
var y = value[1];
[x, y]

 

My main caveat is that you have to pay attention to the first layer's position values if you parent it to a null - and all the position animation to slide all the other layers needs to be done on the first layer or its parent. All the layers kind of pseudo-parented to the layer above them. Hopefully this can trigger an idea! Project file attached.

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Thanks so much for the reply. It is extremely kind of you to furnish me with that expression and project file – it's cool and will def keep in my locker 🙏
But as Dan mentions below, there's so much going on that I fear its beyond my cognitive capacity to create a robust solution. Might be a case of using what I can and keyframing the rest.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

LATEST

Most welcome! 

Ah it's true - Once I started testing this with the proximity animation expression, things got a little wacky. But at least this rig is a decent starting point for evenly distributing randomly sized things! Just not perfect for this use case.

Depending on if you need to reuse the animation or not, sometimes it's worth it to brute force your way with key frames, rather than diving down deep rabbit holes for the perfect expression. 

For what it's worth, when I can't get a technical workflow working, I just go back and ask myself what the design goal is and if there's another effective approach that will save my brain from going nuts.

E.g. If your design goal is to create some visual separation between the scaled up layer and the other layers, maybe it's worth it to look into animating the edges of a mask or track matte on each layer, so your're not fussing with so many position offsets. Or you could add a different proximity animation on an effect that dims the contrast of the layers (e.g. curves) so that the layer you're scaling up also "highlights" as it approaches your target, and "unhighlights" as it animates away.

 

Anyway, good luck! Seems like you have a cool project to develop!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

The problem is that it will be easy to end up with a bunch of position and scale expressions that are fighting each other. Change the scale of one layer, it affects the position of all the other layers, which affects their scale, which affects the position of all the other layers, and so on. I think you would have to do the calculation for all layers on a single layer (like maybe an invisible text layer) which can publish the results so the expressions for the participating layers can just read the text layer and get their assigned results. The algorithm for that single calculation is probably a little tricky. It seems like you'd have to start with the layer that's closest to the target and work outward, in both directions, from there. Solvable, but not simple.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Thanks Dan. Unfortunately I am simple so it might not be solvable. Appreciate your input!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines