ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to make number values change according to slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mathias Kalhauge
How to make number values change according to slider
on Mar 5, 2018 at 1:42:46 pm

Hey, so I'm in the middle of a project where I need numbers from 0 to 100 to change with a slider.
I've made a slider consisting of shapes. I've parrented a Null Object to the shape that will be moving, so I need the expression to change according to the position of the Null Object.
So when the Null Object is in the bottom the number says 0, and when the Null Object is in the top the number says 100.
I know this isn't the best explanation, but I hope it's understandable.


Return to posts index

Andrei Popa
Re: How to make number values change according to slider
on Mar 6, 2018 at 2:19:51 pm

Try this.
layerPosition = thisComp.layer("Null 1").transform.position[1]; //here you put 1 for the y position or 0 for the x position. That depends on how you want to move your null(vertically/horizontally)
botValue = 100;//the value of the position of the null where you want your value to be 0
topValue = 800;//the value of the position of the null where you want your value to be 100
numValue =Math.floor( ( (layerPosition-botValue) / (topValue-botValue) ) * 100)
numValue


Andrei
My Envato portfolio.


Return to posts index

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