How to set driver distance max and min influence? I have drivers set up between two Empties as an experiment (before I move on to more complex endeavors), and I want the scale of one Empty to be controlled by the distance between it and the other Empty - in such a way that when the Empties are at their maximum closeness (0 distance) this is the max value (or 1), and when they are separated by a distance of x this is their min value (or 0). How can I set this up?



In the image above, the distance from "Empty 2" is controlling the X,Y,Z scale of "Empty 1". However, Empty 1 shrinks when Empty 2 is brought closer - which is perfectly logical, but I want the opposite effect. This would allow for more intuitive rigs to be created where an Empty can be brought closer to an Armature's Bone to create an effect.

There may be cases where I want the min value to be greater than zero, so that Empty 1 does not scale down to an infinitely small size and disappear when Empty 2 is moved away past x distance.

I'm sure there's a way to do this with an expression, but how exactly I do not know. Please pardon my weakness when it comes to math and coding.

I tried a few different expressions involving -var or var*-1, but haven't made much progress.
Here's the magic formula for the driver:

1.0 if (var &lt;= 0.0) else 0.0 if (var &gt;= &lt;maxval&gt;) else (&lt;maxval&gt;-var) / (&lt;maxval&gt;)


So if I want my max value to be 5.0, then the formula would look like this.

1.0 if (var &lt;= 0.0) else 0.0 if (var &gt;= 5.0) else (5-var) / (5)