Activity › Forums › Adobe After Effects Expressions › position collision detection to scale output expression
-
position collision detection to scale output expression
Posted by Olly Bea on November 12, 2008 at 4:07 pmHi all
I am trying to write an “if / else” type expression but I am obviously doing something wrong. I want a 3d text layer to scale up to 200% when it hits the position co-ordinates [545,506,0.0] but at all other times be 100%.
How do I write it?
Any help would get me out of a sticky hole!
Cheers
Olly
Justin Sweeney replied 12 years, 6 months ago 3 Members · 9 Replies -
9 Replies
-
Dan Ebberts
November 12, 2008 at 4:42 pmYou probably want something like this:
threshold = .01;
if (length(transform.position,[545,506,0.0]) < threshold){ [200,200,200] }else{ [100,100,100] } Dan -
Olly Bea
November 12, 2008 at 5:32 pmThanks Dan
I’ll give this a whirl, but here is the interesting final step…
Is there a way to say as the 3d text gets within say 10 pixels of the magic position [545,506,0] that it will gradually scale something like 10% per pixel?
Many thanks Dan you are the king!
Olly
-
Dan Ebberts
November 12, 2008 at 5:49 pmI’m thrown by the “per pixel” part. If you’re just talking about scaling the text layer up as it’s anchor point approaches the target position, you could do it like this:
transDist = 10;
target = [545,506,0];d = length(transform.position,target);
mult = ease(d,0,transDist,1.1,1)
value * multDan
-
Olly Bea
November 12, 2008 at 6:10 pmSorry, didn’t mean to confuse.
I am trying to create the effect that, as the 3d text layer nears the exact position [545,506,0.0] it scales up the closer it gets, so as it reaches exactly that position it will be 200%. Does that make sense?
For example; the 3d text layer has a scale of 100% and a position of 445,506,0 (100 frames off, on the x axis) but as it animates near the exact position [545,506,0.0], it scales up. So that by the time it reaches the exact position it is 200%.
Therefore using the figures in this example every 10 pixels it gets closer to the exact position it will scale up 10%.
Or does this just confuse further?
Olly
-
Dan Ebberts
November 12, 2008 at 6:39 pmWell, if all you want to do is scale up as the layer approaches the target position, with a fixed transition distance of 100 pixels, this should work:
transDist = 100;
target = [545,506,0];d = length(transform.position,target);
mult = ease(d,0,transDist,2,1)
value * multHowever, if the transition distance depends on the initial position of the layer, it gets trickier, and you’d need something like this:
target = [545,506,0];
transDist = length(transform.position.valueAtTime(0),target);d = length(transform.position,target);
mult = ease(d,0,transDist,2,1)
value * multThis second version won’t do anything until you actually keyframe the layer moving towards the target.
Dan
-
Olly Bea
November 13, 2008 at 8:20 amThanks Dan both these work a treat.
I’ll try and work out what is going on in each expression, I might have to come back to you with how each one works, because these look a little out of my depth.
Many thanks for your help… once again!
Olly
-
Justin Sweeney
November 1, 2013 at 8:43 pmHi Dan – long time listener, first time caller.
I’m trying to modify this particular script to use a null object’s position to change multiple shape layers’ scale.
All shape layers that have this script grow as the null approaches them, but instead of referencing the null as a single point (x and y position), I’m trying to scale the shape layers along the null’s y axis so no matter where I move the null on the x axis, all shape layers above and below will be scaled.Thanks for your help!
transDist = 200;
target = thisComp.layer("Dot Target 01").transform.position
d = length(transform.position,target);
mult = ease(d,0,transDist,3,1)
value * mult -
Dan Ebberts
November 1, 2013 at 10:10 pmLike this maybe:
transDist = 200;
target = thisComp.layer(“Dot Target 01”).transform.position;
d = Math.abs(target[0]-transform.position[0]);
m = ease(d,0,transDist,3,1)
value * mDan
-
Justin Sweeney
November 4, 2013 at 2:20 pmThanks, Dan, that’s exactly what I was looking for!
For future reference, would there be a way to use the null’s rotation to control the scale effect on an angle?Justin
Reply to this Discussion! Login or Sign Up