I'm trying to move a 3D object on its Y-axis as the value of a null object's rotation changes. This is for a character rig that I'm busy with, so basically, as the null object is rotated on its X-axis (up/down), the object must have a slight offset and have a smooth movement. In this case the character's eye. The null object rotates the body to tilt up and down and therefore the eye should follow realistically.
I have the following code which works, but the eye jumps from the one position to the next as the null reaches a certain value or goes above or below 0:
Based on your code, when the value falls below 35 the y position will instantly pop from 100 to -100, similarly when the value hits 0 the value will instantly pop from -100 to 0. Is that the intention? And when you go below 0 the value will pop to -100 again.
Or do you need something like a range mapper? Where you have a set of values (say 0-35) and you want to linearly map another set of values to that (say -100 to 100).
If you call the set of values 0-35 values set1 and call 100 to 100 value set2 here's the equation for that. Assuming you have a value from set1 (valueFromSet1) that you want to map to the values in set2.
My answer falls under the topic of "when you have a hammer everything looks like a nail".
I had been doing range mappers in another software package when I answered your post and totally forgot about the range expression.
Here's an answer from Jay Roth that I took from a post a few hours after yours. (saves me typing)
I think you'll want the linear expression hooked up to a expression slider on a null.
The linear expression works by taking one set of values doing the math to interpolate them to another set of values. So, you would want to put this expression on the range selector of each of your text layers
range = thisComp.layer("YOUR NULL").effect("Slider Control")("Slider");
linear(range, 0, 10, 0, 100); // Change the first two numbers to be the keyframed values you want for the slider for each layer
Essentially what this is telling the range selector is "As the null slider goes from 0 to 10, change the range selector value from 0 to 100.