ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Slider Control Divided by Zero Expression Error

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rajan Dave
Slider Control Divided by Zero Expression Error
on Jul 24, 2018 at 10:57:11 am

I'm trying to Create Bounce Animation Using This Script in Adobe After Effect CC 2018.

Using Script Link I used

I created Two Layer, One is For Object = Ball, Second is Shadow.
For shadow's position following the Ball layer, Used This script

ball_xPos = thisComp.layer("Ball").transform.xPosition;
def_yPos = transform.position[1];
[ball_xPos, def_yPos]

And into Scale Property, scale - up the shadow when the ball is near and scale - down shadow when the ball is far,
I used This

def_yScale = transform.scale[1];
ball_yPos = thisComp.layer("Ball").transform.yPosition;
ball_yMin = thisComp.layer("Ball").effect("Min. Ball Height")("Slider");
ball_yMax = thisComp.layer("Ball").effect("Max. Ball Height")("Slider");
scale_factor = thisComp.layer("Ball").effect("Shadow Scale Factor")("Slider");

if(ball_yPos &gt; ball_yMin){
ball_yPos = ball_yMin;

if(ball_yPos &lt; ball_yMax){
ball_yPos = ball_yMax;

new_xScale = ball_yPos/scale_factor;

[new_xScale, def_yScale]

Thing is Sliders I declared - Shadow Scale Factor have has zero value.
so at the end when it's divided, giving me an error "Invalid Numeric Value(Divided by Zero?)".

Any Solution regarding this?

How not to set static sliders for animation, take a look at Expression Link I gave, they declared static sliders.

Return to posts index

Dan Ebberts
Re: Slider Control Divided by Zero Expression Error
on Jul 24, 2018 at 3:46:54 pm

>Any Solution regarding this?

Don't let the slider go to zero?

Test for zero before you do the divide?

Trap the error using try/catch?


Return to posts index

Kalleheikki Kannisto
Re: Slider Control Divided by Zero Expression Error
on Jul 25, 2018 at 5:23:27 pm
Last Edited By Kalleheikki Kannisto on Jul 25, 2018 at 5:24:18 pm

I'd go with Dan's first suggestion -- there's no need to scale the shadow larger than the ball, so you can limit the scale factor to always be >=1.

scale_factor = Math.max(1, thisComp.layer("Ball").effect("Shadow Scale Factor")("Slider"));

Kalleheikki Kannisto
Senior Graphic Designer

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved