ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# A Math.sin () but with intervals?

FAQ   •   VIEW ALL
 A Math.sin () but with intervals? on Sep 2, 2018 at 5:20:05 pm

Hi!, I've been trying to figure out an expression that helps me to do an interval movement in the X position to an arm character. I like to swing his arm back and forth on a walk cycle without looping out because I like to pause the movement with an expression and some slider controls. So I was testing the expression Math.sin(value) but the problem that I had is the start position isn't 0

So he result it's something like this:

the expression that was testing is this

I'll appreciate any help, thanks

```minVal = thisComp.layer("R Hand Walk Cycle").effect("rangeMin")("Slider"); maxVal = thisComp.layer("R Hand Walk Cycle").effect("rangeMax")("Slider"); Math.sin(time*thisComp.layer("R Hand Walk Cycle").effect("Velocidad")("Slider"))*(minVal,maxVal)```

 Re: A Math.sin () but with intervals?on Sep 2, 2018 at 6:39:07 pm

I would think you would want to replace the last line with something like this:

avg = (minVal+maxVal)/2;
amp = maxVal - minVal;
avg + amp*Math.sin(time*thisComp.layer("R Hand Walk Cycle").effect("Velocidad")("Slider"))

Dan

 Re: A Math.sin () but with intervals?on Sep 2, 2018 at 6:55:13 pm

Thanks! it works perfectly!

Franco Palacios
http://startupmotion.cl/

 Re: A Math.sin () but with intervals?on Sep 2, 2018 at 7:32:57 pm

That's not quite right. More like this maybe:

avg = (minVal+maxVal)/2;
amp = (maxVal - minVal)/2;
avg + amp*Math.sin(time*thisComp.layer("R Hand Walk Cycle").effect("Velocidad")("Slider"))

Dan