ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Scale related to postion

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Max Wolkowitz
Scale related to postion
on Jul 17, 2017 at 3:20:11 am

I'm trying to figure out how to set up an expression for a face rig.

Here's my character:


Here's what I'm trying to do:
Set it up so that when I move the eyes along the X-axis, the scale decreases slightly as each eye moves away from the center line toward it's own side (left or right). Because of the curve of the face this will just create a more effective movement, but I'd rather not have to set keyframes for scale every time I want to move the eyes.

Any ideas? Thanks!


Return to posts index

Scott McGee
Re: Scale related to postion
on Jul 17, 2017 at 8:24:44 pm

There is probably a better way to write this, but it works. If the eyes are in the centre and move left or right, they do get smaller based on the x Axis.

This is going off if your eyes to start off with are at 100%

x = transform.position[0];
if (x >100) [x-100,x-100]-[transform.scale[0],transform.scale[1]]
else [x, x]


Return to posts index

Max Wolkowitz
Re: Scale related to postion
on Jul 17, 2017 at 8:57:09 pm

This is a good start, and I've adjusted it to do a bit more what I described (expression below), but I'm not sure how to adjust this so that I can affect the rate of the shrinking. Right now it goes down 1% for every pixel it moves. I'd like to it shrink less so that I can move it further away without it disappearing.

x = transform.position[0];
if (x >960) [x-960,x-960]-[transform.scale[0],transform.scale[1]]
else [transform.scale[0],transform.scale[1]]


Return to posts index


Scott McGee
Re: Scale related to postion
on Jul 17, 2017 at 9:23:10 pm

I haven't figure it out the other way as in if it goes left (x<960), but if you /(number of choice) this reduces it.

x = transform.position[0];
if (x >960) [x-960,x-960]/5-[transform.scale[0],transform.scale[1]]
else [transform.scale[0],transform.scale[1]]

Just because I've got another job to work on, but if you figure it out let me know, if not you'll find another post by me tomorrow with an answer probably.


Return to posts index

Scott McGee
Re: Scale related to postion
on Jul 18, 2017 at 7:16:27 am

I came across this trying to find someway of getting the value to spread itself.

This works spot on, so give this a try and see if it's what you want.

f = 2; //factor to increase scale by
min = 0; //distance in pixels from the center where the layer is at full scale
max = 1000; //distance in pixels from the center where the layer is at 'normal' scale
c = [thisComp.width / 2, thisComp.height / 2]; //center of the composition
p = toComp(anchorPoint); //location of the current layer in the composition
d = Math.abs((p - c)[0]); //distance from the center along the x-axis
ease(d, min, max, f * value, value);


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]