Activity › Forums › Adobe After Effects › Expression to push and scale object in different directions?
-
Expression to push and scale object in different directions?
Posted by Shane Brown on March 7, 2024 at 5:10 pmHello, I’m looking for some advice on a method to replicate the attached gif. Basically I want to know how can I have one object affect the position and scale of a neighboring object.
Silas Figueroa replied 2 years, 1 month ago 4 Members · 4 Replies -
4 Replies
-
Graham Quince
March 8, 2024 at 2:53 pmI can’t get any animation in that gif to play, so it is a bit difficult trying to figure out what you’re hoping to achieve, but at a guess, I’d suggest taking a look at the linear expression.
This lets to map one set of values onto another, something like:
var newScale = linear(“moving layer’s”.position[0],250,500,100,25]
[newScale,newScale]
So you could take the moving layer’s position and as it’s X value (position[0]) moves from 250 to 500, the scale drops from 100 to 25.
-
Nils Hammers
March 9, 2024 at 5:23 pmIf I were doing something similar, I’d approach the problem from another direction.
The main object there is that black grid box that scales from zero to hero, to which the pink and gray boxes are pinned (not parented); the pink box will have the anchorPoint snapped to the bottom right corner, the gray box – to the upper left corner.
Expression for the pink box’s position might be something like:
b = thisComp.layer(“BlackBox”) ;
fromComp(b.toComp([0, 0]) ;For the gray box:
b = thisComp.layer(“BlackBox”) ;
fromComp(b.toComp([b.width, b.height]) ;Now, when the black box scales from 0, the pink and gray boxes appear like pulling the opposite corners of black box.
-
Shane Brown
March 11, 2024 at 3:48 amHi Nils, this tip helped me out! I ended up actually using GPT to help me figure this out. This was the solution that got me pretty much close to figuring it out. I added these expressions to the positions of the pink and grey boxes
Pink Shape:
var blackBox = thisComp.layer(“Black Box”);
var blackBoxPosition = blackBox.transform.position;
var blackBoxScale = blackBox.transform.scale[0] / 100;
var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);
var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);
[blackBoxPosition[0] – xOffset, blackBoxPosition[1] – yOffset];
Grey Shape:
var blackBox = thisComp.layer(“Black Box”);
var blackBoxPosition = blackBox.transform.position;
var blackBoxScale = blackBox.transform.scale[0] / 100;
var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);
var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);
[blackBoxPosition[0] + xOffset, blackBoxPosition[1] + yOffset];
-
Silas Figueroa
March 31, 2024 at 12:02 amYou can use a linear scaling expression or a join expression to bind object parameters. This will allow one object to control another depending on certain conditions or movements
Reply to this Discussion! Login or Sign Up