ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Link position to scale expression ?

FAQ   •   VIEW ALL
 Link position to scale expression ? on Apr 14, 2020 at 12:49:16 pm

Hello guys ! First of all hello, this is my first post here ☺

I am doing a bouncing ball animation with expressions and would like to create it's shadow. I'd like to make it scale based on the ball's height (position, more generally), but I am quite running out of ideas to transcribe it's height into a %.. I need help please !

 Re: Link position to scale expression ?on Apr 14, 2020 at 2:22:34 pm

Andrei
My Envato portfolio.

 Re: Link position to scale expression ?on Apr 14, 2020 at 2:23:20 pm

Thank you very much !

 Re: Link position to scale expression ?on Apr 14, 2020 at 6:23:14 pm

After hours of headaches and with the help of my Data scientist father, I was able to make a much simpler and versatile version that revolves around no other constant than a factor unlike school of motion, it also allows you to control the speed of evolution from minimum scale to maximum scale, aswell as the minimum scale ! Thanks for your help I wouldn't have improved without your link !

```Factor = 20 //Control the scale variation, smaller factor = smaller minimum size var diameter = thisComp.layer("Ball").content("Ellipse 1").content("Ellipse Path 1").size[1]; var ball_yPos = thisComp.layer("Ball Pos").transform.position[1]; var ground = thisComp.layer("Ground").transform.position[1]; var hDepart = diameter*2; //Control the scale speed var diff_BallGround = ground - ball_yPos; if (diff_BallGround<hDepart){ //Shadow Scaling substract = (diff_BallGround/Factor) }else{ substract=hDepart/Factor // Minimum size } if (substract&lt;0){ //To prevent the shadow from getting larger substract = 0 } [100-substract,transform.scale[1]]```

 Re: Link position to scale expression ?on Apr 14, 2020 at 2:28:11 pm

This is kind of what you want. I don't have anything that caps it at a percentage, but hopefully it'll get you started.

```posTwo = thisComp.layer("Shape Layer 2").transform.position.key(1).value[1]; currentPos = thisComp.layer("Shape Layer 2").transform.position[1]; x = transform.scale[0] - (100 - (currentPos/posTwo)*100); y = transform.scale[1]; [x,y]```